Multi-threaded application that ensures single-threading of calls to unthreaded Simple API calls runs correctly.

Final Release Note

A multi-threaded application that ensures single-threading of calls to unthreaded Simple API calls (i.e., ensures that calls to the YottaDB engine happen only from one thread at any point in time) runs correctly. An example application is one that uses Flask web framework with the YDBPython wrapper. Previously, such an application could intermittently get %YDB-E-SYSCALL, Error received from system call timer_create() errors. [#935 (closed)]

Description

The following repository has been created as a means of demonstrating the use of a simple CRUD application with Python, the flask web framework and YottaDB:

https://github.com/RamSailopal/flask-yottadb-demo

When running the demo using docker compose, the following error message appears intermittently (more often than not) when trying to create a new user/record/using yottadb.set

flask_flask-back | Traceback (most recent call last):
flask_flask-back |   File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2548, in __call__
flask_flask-back |     return self.wsgi_app(environ, start_response)
flask_flask-back |   File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2528, in wsgi_app
flask_flask-back |     response = self.handle_exception(e)
flask_flask-back |   File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 2525, in wsgi_app
flask_flask-back |     response = self.full_dispatch_request()
flask_flask-back |   File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1822, in full_dispatch_request
flask_flask-back |     rv = self.handle_user_exception(e)
flask_flask-back |   File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1820, in full_dispatch_request
flask_flask-back |     rv = self.dispatch_request()
flask_flask-back |   File "/usr/local/lib/python3.8/dist-packages/flask/app.py", line 1796, in dispatch_request
flask_flask-back |     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
flask_flask-back |   File "/home/flask-back/index.py", line 57, in adduser
flask_flask-back |     yottadb.set("^PATIENTS",(str(id), "name"), str(name))
flask_flask-back |   File "/usr/local/lib/python3.8/dist-packages/yottadb/__init__.py", line 117, in set
flask_flask-back |     _yottadb.set(varname, subsarray, value)
flask_flask-back | _yottadb.YDBError: 150377722,(SimpleAPI),%YDB-E-SYSCALL, Error received from system call timer_create() -- called from module /tmp/yottadb- 
src/sr_unix/gt_timers.c at line 638

The code causing the error can be found here:

https://github.com/RamSailopal/flask-yottadb-demo/blob/main/flask-back/index.py

The yottadb.set command example:

yottadb.set("^PATIENTS",("1", "name"), "Bob Taylor")

On some occasions, an error message will be flagged but data is still written to the database.

I have also tried this using Python via the terminal and the command runs with no issues multiple times, with multiple records.

The critical point to note is that the set works fine, every time, from the terminal but from within Flask, works some times, and "throws" an error at others.

I've built the demo "stack" locally and well as on another (Gitpod) dev environment and the results are the same.

Edited Nov 11, 2022 by Jaahanavee Sikri
Assignee Loading
Time tracking Loading