Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Storing the sqlalchemy session in the bot has some wierd conscequences in case of sql error #66

Open
Paillat-dev opened this issue Jul 26, 2024 · 6 comments · May be fixed by #75
Open
Labels
bug Something isn't working deadline-wontfix This task is too complex and we weren't able to solve it within the coding deadline priority-medium
Milestone

Comments

@Paillat-dev
Copy link
Collaborator

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.IntegrityError) UNIQUE constraint failed: user_list_items.list_id, user_list_items.tvdb_id, user_list_items.kind
[SQL: INSERT INTO user_list_items (list_id, tvdb_id, kind) VALUES (?, ?, ?)]
[parameters: (1, 385376, 'SERIES')]
(Background on this error at: https://sqlalche.me/e/20/gkpj) (Background on this error at: https://sqlalche.me/e/20/7s2a)
@Paillat-dev Paillat-dev added bug Something isn't working priority-high labels Jul 26, 2024
@Paillat-dev Paillat-dev added this to the Required milestone Jul 26, 2024
@Paillat-dev
Copy link
Collaborator Author

Session cannot be stored, it should be used w async with. Or some sort

@ItsDrike
Copy link
Owner

Hmm, well utils/database.py already has get_db_session async context-manager function, maybe we should just use that each time instead of just once in __main__.py

@Paillat-dev
Copy link
Collaborator Author

Yeah because I believe the __aexit__ cleans up stuff, and does rollbacks and things like this

@ItsDrike
Copy link
Owner

Sadly, this we didn't manage to fix this in time, however, it shouldn't affect the bot's functionalities, since we handle the sql errors ourselves, this doesn't propagate up, it's just that the handling isn't ideal.

@ItsDrike ItsDrike closed this as not planned Won't fix, can't repro, duplicate, stale Jul 28, 2024
@ItsDrike ItsDrike added the deadline-wontfix This task is too complex and we weren't able to solve it within the coding deadline label Jul 28, 2024
@Paillat-dev Paillat-dev linked a pull request Jul 28, 2024 that will close this issue
@ItsDrike
Copy link
Owner

There is a post-deadline fix for this that was submitted in #75, it will not be merged into main as that would violate the code-jam's rules, however, I will leave the issue & PR opened just for reference.

@Paillat-dev
Copy link
Collaborator Author

Paillat-dev commented Jul 28, 2024

Marked as priority medium, as sql errors should not happen - all sql errors happened while developement and were mitigated before they would hit the user.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working deadline-wontfix This task is too complex and we weren't able to solve it within the coding deadline priority-medium
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants