You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WPB-29574: migrate client store to PostGreSQL - #5647
…ore tables
The client-store migration creates clients/prekeys/mls_public_keys with CREATE
TABLE IF NOT EXISTS and never alters an existing table; document that operators
with stale tables from an older brig-on-PostgreSQL era must reconcile or drop
them before enabling the migration. postgres-schema.sql already carries all
three table blocks (verified against 20261023090000-client-store.sql).
- Aggregate multiple MLS signature schemes per client with Map.unionWith (<>) in groupMLSPublicKeysByUsers and add Wire.ClientStore.PostgresSpec.
- Reject postgresMigration.clients: migration-to-postgresql at brig startup (Brig.App.newEnv) and fail loudly in Brig.CanonicalInterpreter and removeClientPrekeys.
- Guard hack/helm_vars/common.yaml.gotmpl against PREFERRED_STORE=migration-to-postgresql for clients.
- Update config-options.md (remove non-existent migrateClients, fix client-store migration SQL filename) and add clients: postgresql to gundeck.integration.yaml after #5663 rebase.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
A critical concurrency bug remains in prekey claiming: SKIP LOCKED can incorrectly trigger fallback to the last-resort key while regular prekeys are still available.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The change retains a critical concurrent-claim race that can serve a last-resort key while regular keys remain, and it also rejects duplicate prekey IDs with a PostgreSQL error instead of Cassandra-compatible behavior.
No open issues 🎉
2 previously missed issues
In code that hasn't changed since last review
Retry regular-key claim before falling back to last-resort key
Under PostgreSQL's READ COMMITTED, two concurrent claims can choose the same regular row in this subquery. The second statement waits on FOR UPDATE; after the first transaction deletes the row, its outer DELETE can return no row, and claimPrekeyImpl then falls back directly to selectLastPrekeyStatement, serving the last-resort key even though other regular prekeys remain. Retry/reselect the regular-key claim after an empty result (or use a concurrency-safe claim transaction) before falling back to the last-resort key.
checkPrekeyBundle validates each bundle but does not require distinct IDs, and the public schema accepts arbitrary prekey arrays. Cassandra handles duplicate IDs by issuing separate inserts (the last value wins), whereas this single INSERT ... SELECT ... ON CONFLICT DO UPDATE raises PostgreSQL's cardinality-violation error when the input contains the same (user_id, client_id, key) more than once. A malformed or buggy client can therefore turn an otherwise accepted update/registration into a server error; deduplicate the bundles with Cassandra-compatible last-write-wins semantics before batching, or insert them individually.
this is not critical. it is unlikely that clients send multiple keys with the same ID in one request. if they do the request will fail, that is it. it does not affect any other parts of the system.
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
ok-to-testApproved for running tests in CI, overrides not-ok-to-test if both labels exist
4 participants
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.
https://wearezeta.atlassian.net/browse/WPB-29574
Checklist
changelog.d