Allow insertIgnoreConflict to work with sharding and use it for filecache.#59732
Open
Allow insertIgnoreConflict to work with sharding and use it for filecache.#59732
Conversation
86ac08b to
d821eb2
Compare
nickvergessen
requested changes
Apr 21, 2026
7577060 to
0e35b8c
Compare
ef0ec48 to
6481a5f
Compare
6481a5f to
6cf0d7a
Compare
Member
|
Sharding tests are failing 🙈 |
6cf0d7a to
e3e9529
Compare
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Since the DB adapters insertIgnoreConflict methods are using the conn directly to alter the produced SQL, bypassing the ShardedQueryBuilder logic, hinting for sharded keys didn't work. We need to expose to the QueryBuilder the information that we want to ignore conflicts, and how to handle it. Signed-off-by: Thomas Citharel <tcit@tcit.fr>
…nflicts are properly handled In the FileCache, use insertIgnoreConflict to avoid conflict error messages on PostgreSQL. Use the new optional hintShardKey parameter Closes #19494 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
e3e9529 to
fe78872
Compare
Member
Author
The adapters were calling the connection directly without using the QueryBuilder, so the sharding logic couldn't apply through This focuses on the ignoring conflict cases, but it could be changed a little to have something like a Obviously all of this would be easier if Doctrine DBAL supported ignoring conflicts itself, but 🤷 |
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.
duplicate key value violates unique constraint#19494Summary
Replaces #48564
As we added
hintShardKeyto the query since #48564 was opened, it can't be resolved directly through use ofinsertIgnoreConflictanymore. To sethintShardKeyanyway, I've added an extra optional 3rd parameter to do that.As the
insertIgnoreConflictmethods in the database adapters use the connection directly to alter the produced SQL, bypassing theQueryBuilderand therefore theShardedQueryBuilderwhen sharding is activated, I added aignoreConflictsOnInsertmethod toIQueryBuilderwe can use to tell the QB to apply a callable provided by the DB adapters to alter the produced SQL in this specific case.In
OC\Files\Cache\Cache, I'm bypassing theCacheQueryBuilderand usinginsertIgnoreConflictdirectly on the connection. It's possible this is very wrong, please advise.TODO
CacheQueryBuilderin this case is fineChecklist
3. to review, feature component)stable32)AI (if applicable)