Skip to content
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

Fix: Occasional IntegrityError when saving 'new' assets #30

Merged
merged 5 commits into from
Jul 29, 2024

Conversation

ababic
Copy link
Collaborator

@ababic ababic commented Jul 2, 2024

Downloading asset files can take a while, especially if Bynder is under strain or the connection to Bynder is poor. If multiple editors are working in Wagtail at once and happen choose the same (new) asset at around the same time, they unknowingly take part in a little race: The first request to finish downloading the file and saving the object will succeed, but the other will fail with an IntegrityError because, by the time it tries to write to the DB, an object with the same bynder_id already exists.

A similar issue can also occur whilst saving the object, because it can take a while to copy the file from memory to media storage (which happens before attempting to save to the database). So, we need to account for IntegrityError being raised at that later stage also. And ensure the newly-transferred redundant file is deleted from storage.

@ababic ababic force-pushed the feature/clash-detection branch 4 times, most recently from 1f8510d to 64e471a Compare July 2, 2024 20:02
@ababic ababic marked this pull request as draft July 2, 2024 20:02
@ababic ababic changed the title Fix: IntegrityError when saving 'new' assets Fix: Occasional IntegrityError when saving 'new' assets Jul 5, 2024
@ababic ababic force-pushed the feature/clash-detection branch 8 times, most recently from 4b245f8 to b2956b4 Compare July 5, 2024 16:44
@ababic ababic marked this pull request as ready for review July 5, 2024 16:45
@ababic ababic marked this pull request as draft July 5, 2024 16:54
@ababic ababic force-pushed the feature/clash-detection branch 11 times, most recently from c5ffb58 to 961e6fd Compare July 6, 2024 19:24
@ababic ababic marked this pull request as ready for review July 6, 2024 19:27
@ababic ababic merged commit c61e649 into main Jul 29, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant