Skip to content

fix: leave worker registry unchanged on alias collision - #1440

Merged
brandur merged 3 commits into
riverqueue:masterfrom
flcrom:fix/worker-alias-registration
Oct 10, 2026
Merged

brandur merged 3 commits into
riverqueue:masterfrom
flcrom:fix/worker-alias-registration

Conversation

@flcrom

@flcrom flcrom commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #1433.

Workers.add currently writes the primary kind and earlier aliases before checking later aliases. When a later alias is already registered, AddWorkerSafely returns an error but leaves those new kinds in the registry, preventing a caller from registering replacement workers.

Collect and validate every kind before writing to the map. Keep the existing collision error text and rejection of duplicate kinds within a registration. Add a regression for a late alias collision that checks the registry size and absence of the candidate primary kind and earlier alias.

Validation:

  • The regression fails on the original implementation and passes with the patch, including 30 race-detector repetitions.
  • Public-API recovery and edge checks cover primary/alias collisions, duplicate aliases, preserved occupied workers and valid registrations.
  • Full make test, PostgreSQL and SQLite make test/race, and make lint pass across all nine workspace modules. Lint used v2.13.1 with concurrency=1 for local memory limits.

Local testing used Go 1.26.6 and PostgreSQL 14.24 with UTF8. This does not claim every upstream CI OS/Go/database combination has passed. No registration-after-start behavior is changed.

@brandur

brandur commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

@flcrom Do you want to add yourself to the River CLA https://github.com/riverqueue/rivercla? And add a changelog entry for this as well please.

@flcrom

flcrom commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

CLA is already signed: I'm in signees.csv in riverqueue/rivercla (riverqueue/rivercla#37). Changelog entry added in 3f38b47.

Produces a net reduction in LOCs (-15 lines) for `Workers.add`.
@brandur

brandur commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

@flcrom Ah perfect. Thanks again!

@brandur
brandur merged commit 2f6b27e into riverqueue:master Oct 10, 2026
15 checks passed
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.

AddWorkerSafely leaves registered kinds after an alias collision

2 participants