Open mamarguerat opened 8 months ago
Can you please check the Web API logs? They will show an error if you encounter 500 in the frontend.
[2024-03-18 11:44:55 +0000] [20] [ERROR] Error handling request /api/places/
Traceback (most recent call last):
File "/usr/local/lib/python3.11/dist-packages/gunicorn/workers/sync.py", line 135, in handle
self.handle_request(listener, req, client, addr)
File "/usr/local/lib/python3.11/dist-packages/gunicorn/workers/sync.py", line 178, in handle_request
respiter = self.wsgi(environ, resp.start_response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 1488, in __call__
return self.wsgi_app(environ, start_response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 1466, in wsgi_app
response = self.handle_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 1463, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 872, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 870, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 855, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gramps_webapi/api/auth.py", line 44, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/flask/views.py", line 110, in view
return current_app.ensure_sync(self.dispatch_request)(**kwargs) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/flask/views.py", line 191, in dispatch_request
return current_app.ensure_sync(meth)(**kwargs) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/gramps_webapi/api/resources/base.py", line 448, in post
with DbTxn("Add objects", db_handle) as trans:
File "/usr/local/lib/python3.11/dist-packages/gramps/gen/db/txn.py", line 83, in __exit__
self.db.transaction_commit(self)
File "/usr/local/lib/python3.11/dist-packages/gramps/plugins/db/dbapi/dbapi.py", line 309, in transaction_commit
self.dbapi.commit()
File "/usr/local/lib/python3.11/dist-packages/gramps/plugins/db/dbapi/sqlite.py", line 165, in commit
self.__connection.commit()
sqlite3.OperationalError: database is locked
This is right after successfully adding a place. I cannot edit nor add anything. Is this the log you were requesting?
Yep. Please try adding IGNORE_DB_LOCK=True
to your config file.
(GRAMPSWEB_IGNORE_DB_LOCK: true
if you are using YAML docker environment variables.)
Thanks for your help. It worked, but only for 1 more database edit. Now I can add 2 places before getting the 500 error, and the same log traceback.
Ok, something seems to be wrong either with your setup or with your database. I assume this is not the only object in your database?
Have you ried running check & repair?
I just tried to sync the database with gramps, run a check & repair (1 empty event has been deleted) and sync back the database to gramps web. The issue is still there. It's not the only object in the database, there is about 240 people, 50 medias, 30 places, 400 events.
Please check if there is a lock file in the database directory and delete it manually. Not sure what is wrong there.
I couldn't find any lock file in the database directory.
I found the following error in the log
ERROR:root:Error parsing list of recent DBs from file /root/.gramps/recent-files-gramps.xml: no element found: line 1, column 0.
This might indicate a damage to your files.
If you're sure there is no problem with other files, delete it, and restart Gramps.
How much RAM does your server have?
It has 20GB, shared with other dockers and apps. The memory usage of the whole system is about 40%.
Ok it's an SQLite lock error, not a Gramps one, so there must be two processes trying to write simultaneously to the database. Are you accessing the database with anything else, e.g. syncing in parallel?
Can you try manually unlocking the database using the command line? Perhaps there is some process that crashes before releasing the lock.
I'm not accessing the database with another process. The only thing that access the file is a backup once a day. The backup does not access the database directly, it just copies the database file. How can I unlock the database with the command line ?
Is this error still happening? If you can't confirm, I'll go ahead and close this issue. There have been improvements in v2.3.1 which might well have solved this.
Hi, I tried with v2.3.1 and the error is still happening. The first write to the database after boot can complete successfully. The second and next ones are reporting an error 500 response to the HTTP put message.
Thanks for checking
After successfully adding a place, with name, type, enclosed place and lat-long coordinates, I get an error 500 for any api POST.
It works after a restart, but I can only create 1 place and then it's broken again.
My Gramps Web is installed in a docker container. This issue didn't come with the latest version, it was there before, but still there.