Skip to content

Fix package updates failing on a duplicate tag name - #1993

Merged
Seldaek merged 1 commit into
mainfrom
tag-create-race
Nov 26, 2026
Merged

Seldaek merged 1 commit into
mainfrom
tag-create-race

Conversation

@Seldaek

@Seldaek Seldaek commented Nov 25, 2026

Copy link
Copy Markdown
Member

Package updates could fail with a duplicate key error on tag_name_idx when they introduced a keyword that had no tag yet:

  • Packages built from the same repository update in parallel. Both could look up a new keyword, find no tag, and insert it, so one update failed. Seen in production with adems/adems-asset and adems/dapur-asset, which share AdeMS/dapur-asset.
  • Within a single update, keywords that differ in PHP but are equal under the column collation (aşet and aset) were both persisted as new tags and clashed on flush.

Tag::getByName(..., create: true) now inserts the tag immediately with INSERT ... ON DUPLICATE KEY UPDATE and reads it back, so the second writer reuses the existing row.

Tests: UpdaterTest::testKeywordsEqualUnderTheCollationShareOneTag reproduces the production error without the fix. The new TagGetByNameTest covers 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.

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.
@Seldaek
Seldaek merged commit 80d3873 into main Nov 26, 2026
8 checks passed
@Seldaek
Seldaek deleted the tag-create-race branch November 26, 2026 11:01
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