New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: sqlite3.OperationalError, database is locked #86
Comments
At first sight, it seems like live_mode and user_id values go missing after switching between admin and customer mode. But Python code is hard to me to debug :( |
I added an extra line at the end of worker.py to close database session and it seems to fix the problem. Line added: After this comment here: Line 1533 in a20889d
|
Hello, First of all - understand what SQLite Database work! - You or already in use this database i.e. watch it trough SQLite Viewer or you run same Bot twice (didn't close them properly) |
I understand how SQLite works, but Python+sqlalchemy are new to me. |
From my side Greed Bot work like a charm (Right now i don't use it, but it's not too much addition in Master Branch since September-October) Also it was under:
|
Thanks for the feedback. That's weird then, I'm also running a VPS with SSD (CentOS 8). I'll test on another machine to see how it goes. |
@mastersuv Check that you don't run ./database.py or ./core.py twice. SQLite can handle only one connection at a time. And it handled exactly by database.py which invoked by a worker.py which invoked by a core.py.
So no big changes in library in behaviour on this functions - so it's compaitable with 13. But yes this error even not by a SQLAlchemy it's a SQLite behaviour (Only 1 connection to DB allowed) Have a nice day. |
Thanks, I'll check that out! |
But better if @Steffo99 look at this error - may be when you was in Live mod previously it's not close DB Connection. And it locked down database. |
Yeah, I think I've identified part of the problem. The error always happens when the |
Because when |
Yeah, there are no other admins or users, just me. |
I tried on another computer and is working perfectly fine. No more database locked errors... I was running core.py twice... Duplicated processes. |
Sorry 🤦♂️ |
I was able to reproduce the error! Now let's see what causes it... |
This fix worked! The bot wasn't closing sessions properly on a conversation exit, and it seems it was because of a line that was missing since the first commits of the bot ( 5f04a1f )! I'm committing that in your name, so to give proper credit. Thank you! |
Fixed with 3915bb7 . |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
@laskriabdellah has reported that the issue has somehow resurfaced in: #201 (comment) |
@laskriabdellah, can you provide some debug logs? In # Logging settings
[Logging]
# The output format for the messages printed to the console
# See https://docs.python.org/3/library/logging.html#logrecord-attributes for information about the {}-attributes
format = "{asctime} | {threadName} | {name} | {message}"
# Logging level: ignore all log entries with a level lower than the specified one
# Valid options are FATAL, ERROR, WARNING, INFO, and DEBUG
level = "DEBUG" Please post the results here! |
How to reproduce:
CRASH.
Sqlite exception. Database is locked.
Exception in <Worker 763512861>: (sqlite3.OperationalError) database is locked [SQL: UPDATE admins SET live_mode=? WHERE admins.user_id = ?] [parameters: (0, 763512861)] (Background on this error at: http://sqlalche.me/e/13/e3q8)
The text was updated successfully, but these errors were encountered: