Repository navigation
WPB-29583: migrate user client index store to PostGreSQL - #5648
blackheaven wants to merge 4 commits into
Conversation
c4107c7 to
a78a8d5
Compare
a78a8d5 to
3d515e9
Compare
3d515e9 to
3b8b9e9
Compare
3b8b9e9 to
31ce7c6
Compare
31ce7c6 to
57be34e
Compare
57be34e to
1ac3dd2
Compare
1ac3dd2 to
b8138dc
Compare
b8138dc to
9ced570
Compare
870d4b0 to
f28fbe5
Compare
f28fbe5 to
3b9953c
Compare
3b9953c to
ef4afe7
Compare
ef4afe7 to
b7010c0
Compare
battermann
left a comment
There was a problem hiding this comment.
In general, can we think about merging brig and galleys client tables in postgres?
- Read galley/background-worker UserClientIndexStore directly from brig's shared PostgreSQL clients table instead of adding a separate user_client_index table or userClientIndex config key. - Keep CreateClient, DeleteClient, and DeleteClients as no-ops on PostgreSQL (brig owns all writes to clients, and DeleteClients must not delete rows before brig removes prekeys). - Add ShouldRemoveClient to UserClientIndexStore (checks Cassandra index for early-exit; returns True on PostgreSQL so async MLS cleanup in rmClient still runs after brig deletes the client row) and add Wire.ConversationSubsystem.ClientsSpec. - Reject postgresMigration.clients: migration-to-postgresql at startup in galley (validateOptions) and background-worker (mkEnv), and fail loudly in both interpreter switches. - Update config-options.md, hack/helm_vars/common.yaml.gotmpl comment, and add changelog entry.
b7010c0 to
9cc16ec
Compare
|
Done — reworked #5648 to read galley/background-worker's |
There was a problem hiding this comment.
🟡 Changes recommended
A moderate active finding remains because the new PostgreSQL interpreter and its SQL/result grouping lack tests for key cases such as multiple users, duplicate IDs, and users with no rows.
1 open issue
What changed in this PR
Migrates Galley and background-worker user client index reads to Brig’s shared PostgreSQL clients table while preserving Cassandra behavior.
Changes:
- Adds PostgreSQL support and runtime backend selection.
- Updates cleanup handling, validation, tests, documentation, Helm configuration, and changelog.
| File | Description |
|---|---|
| services/galley/src/Galley/App.hs | Selects the configured user client index backend. |
| services/background-worker/src/Wire/Effects.hs | Wires the configured PostgreSQL or Cassandra client index interpreter. |
| services/background-worker/src/Wire/BackgroundWorker/Env.hs | Validates supported client migration settings. |
| libs/wire-subsystems/wire-subsystems.cabal | Registers the new client index module and tests. |
| libs/wire-subsystems/test/unit/Wire/ConversationSubsystem/ClientsSpec.hs | Tests client-removal behavior and migration validation. |
| libs/wire-subsystems/src/Wire/UserClientIndexStore/Postgres.hs | Implements PostgreSQL client index queries. |
| libs/wire-subsystems/src/Wire/UserClientIndexStore/Cassandra.hs | Adds Cassandra client removal checks. |
| libs/wire-subsystems/src/Wire/UserClientIndexStore.hs | Extends the client index effect API with removal checks. |
| libs/wire-subsystems/src/Wire/ConversationSubsystem/Clients.hs | Uses the client index removal-check operation. |
| hack/helm_vars/common.yaml.gotmpl | Configures supported client migration behavior. |
| docs/src/developer/reference/config-options.md | Documents PostgreSQL client store configuration and behavior. |
| changelog.d/5-internal/WPB-29583-migration-postgres-user-client-index | Records the PostgreSQL user client index migration. |
Review effort: Lite
| GetClients uids | ||
| | null uids -> pure (Clients.fromList []) | ||
| | otherwise -> do | ||
| rows <- V.toList <$> runStatement uids selectClientIdsBulkStatement | ||
| pure . Clients.fromUserClients . UserClients $ | ||
| Map.fromListWith | ||
| Set.union | ||
| ([(u, Set.empty) | u <- uids] <> [(u, Set.singleton c) | (u, c) <- rows]) |
| CreateClient _ _ -> pure () | ||
| DeleteClient _ _ -> pure () | ||
| DeleteClients _ -> pure () | ||
| ShouldRemoveClient _ _ -> pure True |


https://wearezeta.atlassian.net/browse/WPB-29583
Stacked on #5647 (WPB-29574, client store) — both surface the same
clientsdata; merge order enforced by the base branch.Checklist
changelog.d