Database connection management #261
No reviewers
Labels
No labels
bug
config update
documentation
duplicate
enhancement
in dev
input needed
new feature
not in draft
refactor
waiting on docs update
wont-do
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Sirdog/EnduraBot!261
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refact/db-connections"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Wow. That was... a lot.
So, as mentioned in #253, my database connection management was very poor. I followed what worked, but it working was mostly because this is a very low traffic Discord bot and
sqlite3is very forgiving.Things improved:
main.py(long-lived connections).sqlite3cursor is handled per-method to mitigate against a situation where 2 different methods want to use the same cursor at the same milisecond, which may cause threading violations.check_same_threadset toFalseto allow the same connection to be used anywhere in the bot, mitigating against lock conflicts.with CLASS_NAME as db...) throughout rather than initiating the class per cog, which is what caused the leaked connectionsThis should improve stability considerably.
Closes #253