WPB-22963 migrate domain registration data to postgres#5195
WPB-22963 migrate domain registration data to postgres#5195battermann wants to merge 18 commits intodevelopfrom
Conversation
e83f366 to
41254ac
Compare
2ee5b64 to
cb09d5a
Compare
There was a problem hiding this comment.
Pull request overview
This PR extends the existing Cassandra→PostgreSQL migration framework to cover domain registration data, including new Postgres-backed store interpreters, a dual-write migration mode, a background-worker backfill job, and config/chart/doc updates to support operating and rolling out the migration safely.
Changes:
- Add Postgres + dual-write interpreters for
DomainRegistrationStoreandDomainVerificationChallengeStore, and wire them into Brig viapostgresMigration.domainRegistration. - Add a background-worker migration loop for backfilling domain registration data from Cassandra to Postgres, plus Prometheus metrics.
- Update Helm/config/docs to add the new
postgresMigration.domainRegistrationfield and make Galley’spostgresMigrationvalues the single source of truth for Brig/background-worker.
Reviewed changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| services/galley/galley.integration.yaml | Adds domainRegistration to integration postgresMigration settings. |
| services/brig/src/Brig/Options.hs | Plumbs PostgresMigrationOpts into Brig options. |
| services/brig/src/Brig/CanonicalInterpreter.hs | Selects Cassandra/Postgres/dual-write interpreters for domain registration + challenge stores; adds migration lock error mapping and Cassandra client input. |
| services/brig/src/Brig/App.hs | Adds postgresMigration into Brig runtime environment. |
| services/brig/brig.integration.yaml | Adds postgresMigration.domainRegistration integration config. |
| services/background-worker/test/Test/Wire/Util.hs | Updates test env PostgresMigrationOpts with domainRegistration. |
| services/background-worker/test/Test/Wire/BackendNotificationPusherSpec.hs | Updates test env PostgresMigrationOpts with domainRegistration. |
| services/background-worker/src/Wire/PostgresMigrations.hs | Adds background-worker migration entrypoint for domain registration. |
| services/background-worker/src/Wire/BackgroundWorker/Options.hs | Adds migrateDomainRegistration flag to options. |
| services/background-worker/src/Wire/BackgroundWorker.hs | Runs domain registration migration loop when enabled and adds it to cleanup concurrency. |
| services/background-worker/background-worker.integration.yaml | Adds migrateDomainRegistration and postgresMigration.domainRegistration integration config. |
| postgres-schema.sql | Adds new Postgres tables/indexes/constraints for domain registration + updates dump version. |
| libs/wire-subsystems/wire-subsystems.cabal | Exposes newly added store/migration modules in the subsystems library. |
| libs/wire-subsystems/src/Wire/PostgresMigrationOpts.hs | Adds domainRegistration :: StorageLocation to migration settings parsing. |
| libs/wire-subsystems/src/Wire/MigrationLock.hs | Adds MigrationLockError→HttpError mapping helper used by Brig. |
| libs/wire-subsystems/src/Wire/DomainVerificationChallengeStore/Postgres.hs | New Postgres interpreter for domain verification challenges. |
| libs/wire-subsystems/src/Wire/DomainVerificationChallengeStore/DualWrite.hs | New Cassandra→Postgres dual-write interpreter for challenges. |
| libs/wire-subsystems/src/Wire/DomainVerificationChallengeStore/Cassandra.hs | Refactors Cassandra interpreter to use Input ClientState via embedClientInput. |
| libs/wire-subsystems/src/Wire/DomainRegistrationStore/Postgres.hs | New Postgres interpreter for domain registrations (+ exists). |
| libs/wire-subsystems/src/Wire/DomainRegistrationStore/Migration.hs | New backfill migration loop from Cassandra to Postgres with locking. |
| libs/wire-subsystems/src/Wire/DomainRegistrationStore/DualWrite.hs | New dual-write interpreter (Cassandra source-of-truth, mirror writes to Postgres under locks). |
| libs/wire-subsystems/src/Wire/DomainRegistrationStore.hs | Adds Postgres marshalling/unmarshalling + migration-lock keying; exports internal store ops. |
| libs/wire-subsystems/postgres-migrations/20260420134603-domain_registration.sql | Adds schema migration for domain registration tables and indexes. |
| libs/wire-api/src/Wire/API/PostgresMarshall.hs | Adds Postgres marshalling/unmarshalling instances needed by the new stores. |
| integration/test/Testlib/ModService.hs | Ensures dynamic backend wiring sets background-worker’s cassandraBrig.keyspace. |
| integration/test/Test/Migration/DomainRegistration.hs | New integration test that exercises migration phases and verifies behavior across cutover. |
| integration/integration.cabal | Registers the new migration integration test module. |
| hack/helm_vars/wire-server/values.yaml.gotmpl | Adds domainRegistration store preference and moves background-worker migration config to Galley source-of-truth. |
| hack/helm_vars/common.yaml.gotmpl | Adds domainRegistration preferred store value. |
| docs/src/developer/reference/config-options.md | Updates docs to describe domainRegistration and the new “Galley as source-of-truth” pattern. |
| charts/wire-server/values.yaml | Adds domainRegistration to galley.config.postgresMigration and adds migration flag docs. |
| charts/wire-server/templates/brig/configmap.yaml | Injects postgresMigration into Brig from Galley chart values. |
| charts/wire-server/templates/background-worker/configmap.yaml | Injects postgresMigration into background-worker from Galley chart values; adds migrateDomainRegistration. |
| changelog.d/0-release-notes/WPB-22963 | Release notes for new migration setting and Helm/value implications. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| setField "cassandra.keyspace" resource.berGundeckKeyspace | ||
| >=> setField "cassandraGalley.keyspace" resource.berGalleyKeyspace, | ||
| >=> setField "cassandraGalley.keyspace" resource.berGalleyKeyspace | ||
| >=> setField "cassandraBrig.keyspace" resource.berBrigKeyspace, |
There was a problem hiding this comment.
this used to be a thing already in background-worker's options, but i guess it hasn't had any integration tests so there was no need to set it here, is that correct?
| eithErr <- runError (runError action) | ||
| case eithErr of | ||
| Right (Right _) -> pure () | ||
| Right (Left e) -> logError (show e) | ||
| Left e -> logError (show e) |
There was a problem hiding this comment.
could be done with join, but maybe your way's prettier?
There was a problem hiding this comment.
IIRC, only if we convert both lefts to text, because they do not have the same type. Which makes this less nice.
| interpretDomainVerificationChallengeStoreToCassandra casClient ttl = | ||
| runInputConst ttl | ||
| . runEmbedded (runClient casClient) | ||
| . interpret | ||
| ( \case | ||
| Insert challenge -> insertImpl challenge | ||
| Lookup challengeId -> lookupImpl challengeId | ||
| Delete challengeId -> deleteImpl challengeId | ||
| ) | ||
| . raiseUnder2 | ||
| interpretDomainVerificationChallengeStoreToCassandra ttl = | ||
| interpret | ||
| ( \case | ||
| Insert challenge -> embedClientInput $ insertImpl ttl challenge | ||
| Lookup challengeId -> embedClientInput $ lookupImpl challengeId | ||
| Delete challengeId -> embedClientInput $ deleteImpl challengeId | ||
| ) |
There was a problem hiding this comment.
i'm not opposed, but why bother?
There was a problem hiding this comment.
can't remember, but there was a reason 😄
Checklist
changelog.d