Skip to content

WPB-22954: migrate mls-commit-locks to PostGreSQL - #5415

Open
blackheaven wants to merge 9 commits into
developfrom
gdifolco/WPB-22954-migration-postgres-mls-commit-locks
Open

WPB-22954: migrate mls-commit-locks to PostGreSQL#5415
blackheaven wants to merge 9 commits into
developfrom
gdifolco/WPB-22954-migration-postgres-mls-commit-locks

Conversation

@blackheaven

Copy link
Copy Markdown
Contributor

https://wearezeta.atlassian.net/browse/WPB-22954

Checklist

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

@blackheaven
blackheaven requested review from a team as code owners August 4, 2026 16:11
@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label Aug 4, 2026

@akshaymankar akshaymankar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we need to migrate these locks? Can we not just use some pg advisory locks instead of creating a table?

@blackheaven

Copy link
Copy Markdown
Contributor Author

Agreed — no table needed. This is now a direct cutover to pg advisory locks (cc03ef9), reusing the same session-scoped advisory-lock mechanism as the domain-registration/team-feature dual-writes (Wire.MigrationLock), with a new non-blocking tryWithMigrationLock variant so contention still answers stale-message instantly. Crash safety comes from the holding connection dying instead of the 10-minute TTL, and locks are not replicated (they vanish on PG failover) — both trade-offs are documented on the interpreter. Since live locks evaporate within 10 minutes and every commit re-acquires, no backfill worker or storage flag is needed; the cutover is just the deploy. The dual-write interpreter, backfill job, migration SQL and the mlsCommitLocks/migrateMLSCommitLocks knobs are deleted; the Cassandra table becomes unread and can be dropped in a follow-up (along with galley schema V68).

Migrate the MLS commit-lock store (galley) from Cassandra to PostgreSQL
using the dual-write + background-worker pattern, following the CodeStore
recipe. The Postgres acquire replicates Cassandra's IF NOT EXISTS USING TTL
via INSERT ... ON CONFLICT DO UPDATE WHERE expires_at < now() RETURNING,
honoring both CAS mutual exclusion and TTL expiry (a pure DO NOTHING would
leave an expired lock blocking its (group_id, epoch) forever, since Postgres
has no TTL reaper). Adds Postgres/DualWrite/Migration interpreters, a
migration flag + metrics, helm/config/docs wiring, schema migration, and an
integration test.
Replaces the mls_commit_locks table + dual-write + backfill migration
from the previous commit with a direct cutover to session-scoped pg
advisory locks (Wire.MigrationLock try-lock). Contention answers
stale-message immediately; crash safety comes from the holding
connection dying instead of the 10-minute TTL. Deletes the
MLSCommitLockStore.DualWrite/Migration modules, the background-worker
migration job, the 20260804143320 SQL migration and all
mlsCommitLocks/migrateMLSCommitLocks config knobs. The cassandra
mls_commit_locks table becomes unread; dropping it (and galley schema
V68) is a follow-up.
@blackheaven
blackheaven force-pushed the gdifolco/WPB-22954-migration-postgres-mls-commit-locks branch from cc03ef9 to abc0f6f Compare September 3, 2026 00:55
A rebase onto develop with bad conflict resolutions silently reverted
newer upstream work: cannon.configuratorImage in the wire-server chart
values (broke the kube-integration CI helm render at
cannon/statefulset.yaml:146), the background-worker user-migration
wiring (migrateUsers), meetings time-setting values/docs, and a
separator line in postgres-schema.sql. Restore all of these from
origin/develop; the MLS advisory-lock cutover needs none of the
reverted content.
randomUser users are not connected, so galley rejects the commit bundle
with 403 not-connected. Use createAndConnectUsers, matching the old
testCommitLock and the other integration-package MLS tests.
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.

3 participants