-
Notifications
You must be signed in to change notification settings - Fork 383
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
[db] Eliminating duplicate key constraint violations #3712
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add test cases. Please reproduce the error and check if it is solved after the change.
filepath=file_path, | ||
filename=os.path.basename(file_path), | ||
content_hash=content_hash).on_conflict_do_nothing( | ||
index_elements=['id']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index_elements=["content_hash"]?? Shouldn't we list the key clashing constraint fields here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can test this fix and provoke the error by storing a file to the server (with masstore run) that has been stored already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[2022-08-15 09:30:01 UTC] (23505) - ERROR: duplicate key value violates unique constraint "uq_files_filepath"
[2022-08-15 09:30:01 UTC] (23505) - DETAIL: Key (filepath, content_hash)=(/path/to/blabla.h, <hash_value>) already exists.
[2022-08-15 09:30:01 UTC] <???> (23505) - STATEMENT: INSERT INTO files (filepath, filename, content_hash, remote_url, tracking_branch) VALUES ('/path/to/blabla.h', 'blabla.h', '<hash_value>', NULL, NULL) RETURNING files.id
In concurrent storage of two runs containing the same files leads to duplicate key constraint violation. Some DBMSs can gracefully handle this issue by supporting "ON CONFLICT DO NOTHING" clause at INSERT statement.
ef405cb
to
eebce30
Compare
In concurrent storage of two runs containing the same files leads to
duplicate key constraint violation. Some DBMSs can gracefully handle
this issue by supporting "ON CONFLICT DO NOTHING" clause at INSERT
statement.