Repository navigation
Fix package updates failing on a duplicate tag name - #1993
Merged
Merged
Conversation
When a package update introduced a keyword that had no tag yet, the tag was only persisted and written on flush. Two packages built from the same repository update in parallel, so both could miss the tag and insert it, failing one update with a duplicate key on tag_name_idx. The same happened within a single update when composer.json listed keywords that differ in PHP but are equal under the column collation, such as "aşet" and "aset". New tags are now inserted immediately with INSERT ... ON DUPLICATE KEY UPDATE and read back, so whichever update gets there second reuses the existing tag.
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.
Package updates could fail with a duplicate key error on
tag_name_idxwhen they introduced a keyword that had no tag yet:adems/adems-assetandadems/dapur-asset, which shareAdeMS/dapur-asset.aşetandaset) were both persisted as new tags and clashed on flush.Tag::getByName(..., create: true)now inserts the tag immediately withINSERT ... ON DUPLICATE KEY UPDATEand reads it back, so the second writer reuses the existing row.Tests:
UpdaterTest::testKeywordsEqualUnderTheCollationShareOneTagreproduces the production error without the fix. The newTagGetByNameTestcovers creation without a flush, reuse of a row inserted elsewhere, collation-equal names, and the no-create path. The cross-worker race itself isn't simulated, since that would need two concurrent connections interleaving the lookup and the insert.