Server: Fix unique constraint error when multiple createSharedFolderUserItems are run concurrently#13112
Merged
laurent22 merged 3 commits intolaurent22:devfrom Sep 8, 2025
Conversation
…UserItems` are run concurrently May partially resolve laurent22#12075.
| }); | ||
| } | ||
| } catch (error) { | ||
| if (!options.ignoreAlreadyExists || !isUniqueConstraintError(error)) { |
Collaborator
Author
There was a problem hiding this comment.
Suggested change
| if (!options.ignoreAlreadyExists || !isUniqueConstraintError(error)) { | |
| if (!isUniqueConstraintError(error)) { |
Some (almost all?) calls to UserItemModel.add/UserItemModel.addMulti are already wrapped in a try/catch that ignores unique constraint errors (example). It could make sense to remove the option and always ignore unique constraint errors here.
Collaborator
Author
|
Closing temporarily until the following in-CI test failure is resolved: |
Collaborator
Author
|
I'm re-running CI — the most recent failing test seems unrelated to this pull request: |
| item_name: item.name, | ||
| type: ChangeType.Create, | ||
| previous_item: '', | ||
| await this.withTransaction(async () => { |
Collaborator
Author
There was a problem hiding this comment.
This withTransaction has been moved within the for loop to avoid the following error observed while running tests in CI: current transaction is aborted, commands ignored until end of transaction block.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request ignores "unique constraint" thrown while adding
(user_id, item_id)pairs touser_itemswhile accepting a share. (See comment).May partially resolve #12075.
Testing
This pull request includes an automated test that runs
createSharedFolderUserItemsmultiple times concurrently (as could happen if the same share is accepted multiple times concurrently).With this change, the sync fuzzer fails after 22 steps, with conflicts (currently expected, see #12993).