-
Notifications
You must be signed in to change notification settings - Fork 39
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
Warning raised during deletion #360
Comments
I did a little digging and found the bug. It has to do with double deletion of database entries. Note: all of the code referenced refers to the file Bug explanationThe bug is in def update_local_storage(session: Session,
remote_sources: List[SDKSource],
remote_submissions: List[SDKSubmission],
remote_replies: List[SDKReply],
data_dir: str) -> None:
local_sources = get_local_sources(session)
local_files = get_local_files(session)
local_messages = get_local_messages(session)
local_replies = get_local_replies(session)
remote_messages = [x for x in remote_submissions if x.filename.endswith('msg.gpg')]
remote_files = [x for x in remote_submissions if not x.filename.endswith('msg.gpg')]
update_sources(remote_sources, local_sources, session, data_dir)
update_files(remote_files, local_files, session, data_dir)
update_messages(remote_messages, local_messages, session, data_dir)
update_replies(remote_replies, local_replies, session, data_dir) When a source is deleted all of the files, messages and replies are deleted from the db as well since they are deleted in cascade with the source according to But because Solution approachEither call the def update_local_storage(session: Session,
remote_sources: List[SDKSource],
remote_submissions: List[SDKSubmission],
remote_replies: List[SDKReply],
data_dir: str) -> None:
remote_messages = [x for x in remote_submissions if x.filename.endswith('msg.gpg')]
remote_files = [x for x in remote_submissions if not x.filename.endswith('msg.gpg')]
update_sources(remote_sources, get_local_sources(session), session, data_dir)
update_files(remote_files, get_local_files(session), session, data_dir)
update_messages(remote_messages, get_local_messages(session), session, data_dir)
update_replies(remote_replies, get_local_replies(session), session, data_dir) Or alternatively remove the CommentsI'll gladly do a PR for this. Just tell me the solution approach you prefer. |
good debugging! I like the first solution (calling |
warnings were caused by double deletion of messages - once upon updating the sources - another upon updating files, messages and replies
close #360 fix db warnings upon source deletion
A warning is raised about potentially un-deleted rows when deleting a source.
STR
Expected
There are not any warnings issued.
Actual
Notes
The rows are correctly deleted from the database, but what is likely happening is the deletion is happening in such a way that SQLAlchemy assumes that it is correctly tracking both Python objects and their related database objects and some code violates these assumptions. SQLAlchemy thinks something went wrong and throws this warning.
The text was updated successfully, but these errors were encountered: