I have a python project set up with SQLAlchemy for an SQLite database, first I recently…
- User
I have a python project set up with SQLAlchemy for an SQLite database, first I recently introduced async to the database code, where I use os.walk to scan for and add files to the database, as well as hashing the files, it worked fine on a smaller folder structure with only around 14 files, but when I tried on a larger folder with hundreds of files(potentially thousands), it seemed to run into issues with the async nature of my calls, so other database interactions failed due to the database being locked, here is some of the errors:
Traceback (most recent call last): File "D:\AI Generation\Projects\vision-8b-minicpm-gradio-webui\app.py", line 154, in register_file await db.commit() File "D:\AI Generation\Projects\vision-8b-minicpm-gradio-webui\venv\lib\site-packages\sqlalchemy\ext\asyncio\session.py", line 1009, in commit await greenlet_spawn(self.sync_session.commit) File "D:\AI Generation\Projects\vision-8b-minicpm-gradio-webui\venv\lib\site-packages\sqlalchemy\util\_concurrency_py3k.py", line 190, in greenlet_spawn result = context.switch(*args, **kwargs) File "D:\AI Generation\Projects\vision-8b-minicpm-gradio-webui\venv\lib\site-packages\sqlalchemy\orm\session.py", line 2017, in commit trans.commit(_to_root=True) File "<string>", line 2, in commit File "D:\AI Generation\Projects\vision-8b-minicpm-gradio-webui\venv\lib\site-packages\sqlalchemy\orm\state_changes.py", line 103, in _go self._raise_for_prerequisite_state(fn.__name__, current_state) File "D:\AI Generation\Projects\vision-8b-minicpm-gradio-webui\venv\lib\site-packages\sqlalchemy\orm\session.py", line 973, in _raise_for_prerequisite_state raise sa_exc.PendingRollbackError( sqlalchemy.exc.PendingRollbackError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (sqlite3.OperationalError) database is locked [SQL: INSERT INTO files (path, type, size, file_created_at, file_updated_at, created_at, updated_at) VALUES (?, ?, ?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) RETURNING id, created_at, updated_at] [parameters: ('D:\\AI Generation\\_Repository\\models\\lora\\SDXL\\harpSY.prompts.txt', 'text/plain', 810, '2024-07-01 10:29:33.508848', '2024-07-01 10:29:33.509347')] (Background on this error at: https://sqlalche.me/e/20/e3q8) (Background on this error at: https://sqlalche.me/e/20/7s2a) Task exception was never retrieved future: <Task finished name='Task-59' coro=<register_file() done, defined at D:\AI Generation\Projects\vision-8b-minicpm-gradio-webui\app.py:107> exception=PendingRollbackError("This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (sqlite3.OperationalError) database is locked\n[SQL: INSERT INTO files (path, type, size, file_created_at, file_updated_at, created_at, updated_at) VALUES (?, ?, ?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) RETURNING id, created_at, updated_at]\n[parameters: ('D:\\\\AI Generation\\\\_Repository\\\\models\\\\lora\\\\SDXL\\\\shizune-pdxl-nvwls-v1.civitai.model-version.json', 'application/json', 16461, '2024-05-19 09:39:28.685997', '2024-05-19 09:39:28.685997')]\n(Background on this error at: https://sqlalche.me/e/20/e3q8)")> Traceback (most recent call last): File "D:\AI Generation\Projects\vision-8b-minicpm-gradio-webui\app.py", line 154, in register_file await db.commit() File "D:\AI Generation\Projects\vision-8b-minicpm-gradio-webui\venv\lib\site-packages\sqlalchemy\ext\asyncio\session.py", line 1009, in commit await greenlet_spawn(self.sync_session.commit) File "D:\AI Generation\Projects\vision-8b-minicpm-gradio-webui\venv\lib\site-packages\sqlalchemy\util\_concurrency_py3k.py", line 190, in greenlet_spawn result = context.switch(*args, **kwargs) File "D:\AI Generation\Projects\vision-8b-minicpm-gradio-webui\venv\lib\site-packages\sqlalchemy\orm\session.py", line 2017, in commit trans.commit(_to_root=True) File "<string>", line 2, in commit File "D:\AI Generation\Projects\vision-8b-minicpm-gradio-webui\venv\lib\site-packages\sqlalchemy\orm\state_changes.py", line 103, in _go self._raise_for_prerequisite_state(fn.__name__, current_state) File "D:\AI Generation\Projects\vision-8b-minicpm-gradio-webui\venv\lib\site-packages\sqlalchemy\orm\session.py", line 973, in _raise_for_prerequisite_state raise sa_exc.PendingRollbackError( sqlalchemy.exc.PendingRollbackError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (sqlite3.OperationalError) database is locked [SQL: INSERT INTO files (path, type, size, file_created_at, file_updated_at, created_at, updated_at) VALUES (?, ?, ?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) RETURNING id, created_at, updated_at] [parameters: ('D:\\AI Generation\\_Repository\\models\\lora\\SDXL\\shizune-pdxl-nvwls-v1.civitai.model-version.json', 'application/json', 16461, '2024-05-19 09:39:28.685997', '2024-05-19 09:39:28.685997')] (Background on this error at: https://sqlalche.me/e/20/e3q8) (Background on this error at: https://sqlalche.me/e/20/7s2a) - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.