Skip to content

WPB-22963 migrate domain registration data to postgres#5195

Open
battermann wants to merge 18 commits intodevelopfrom
WPB-22963-migrate-domain-registration-data-to-postgres
Open

WPB-22963 migrate domain registration data to postgres#5195
battermann wants to merge 18 commits intodevelopfrom
WPB-22963-migrate-domain-registration-data-to-postgres

Conversation

@battermann
Copy link
Copy Markdown
Contributor

@battermann battermann commented Apr 21, 2026

Checklist

  • Add a new entry in an appropriate subdirectory of changelog.d
  • Read and follow the PR guidelines

@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label Apr 21, 2026
@battermann battermann force-pushed the WPB-22963-migrate-domain-registration-data-to-postgres branch from e83f366 to 41254ac Compare April 21, 2026 16:04
@battermann battermann force-pushed the WPB-22963-migrate-domain-registration-data-to-postgres branch from 2ee5b64 to cb09d5a Compare April 30, 2026 15:22
@battermann battermann marked this pull request as ready for review May 6, 2026 15:05
@battermann battermann requested review from a team as code owners May 6, 2026 15:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 DomainRegistrationStore and DomainVerificationChallengeStore, and wire them into Brig via postgresMigration.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.domainRegistration field and make Galley’s postgresMigration values 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 MigrationLockErrorHttpError 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.

Comment thread postgres-schema.sql
Comment thread libs/wire-subsystems/postgres-migrations/20260420134603-domain_registration.sql Outdated
Comment thread libs/wire-subsystems/src/Wire/DomainRegistrationStore/Migration.hs Outdated
battermann and others added 2 commits May 7, 2026 06:57
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,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly

Comment on lines +178 to +182
eithErr <- runError (runError action)
case eithErr of
Right (Right _) -> pure ()
Right (Left e) -> logError (show e)
Left e -> logError (show e)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be done with join, but maybe your way's prettier?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, only if we convert both lefts to text, because they do not have the same type. Which makes this less nice.

Comment on lines -41 to +48
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
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not opposed, but why bother?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't remember, but there was a reason 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants