You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two users editing the metadata of the same image at the same time can lead to data loss. For example:
Image with title field as “Old title”
User A opens the editing form
User B opens the editing form
User B changes the title field to “New title from B”
User B presses save
User A changes another field without changing the title
User A presses save
Image is saved with the title “Old title” (edit from User B is lost)
Django has the select_for_update method, which blocks DB transactions for specific fields. But this is more of a low-level function to prevent concurrent transactions, when the block is released the waiting transaction is applied. Which in our case would also cause data loss.
The text was updated successfully, but these errors were encountered:
One solution is to have an is_locked = True/False boolean field in Media. Every time a user opens the editor, is_locked is set to True. If another user tries to edit the same image, it'll get an error saying the image is locked. Once the image is saved by the first user, is_locked is set to False. Now another user can edit the image using the up-to-date metadata.
To update the is_locked field, we should use the query set update() method instead of the model save() to avoid triggering unnecessarily auto-fields like the date_modified timestamp.
Two users editing the metadata of the same image at the same time can lead to data loss. For example:
Django has the
select_for_update
method, which blocks DB transactions for specific fields. But this is more of a low-level function to prevent concurrent transactions, when the block is released the waiting transaction is applied. Which in our case would also cause data loss.The text was updated successfully, but these errors were encountered: