WPB-22970: migrate activation-keys to PostGreSQL - #5417
Open
blackheaven wants to merge 2 commits into
Open
Conversation
akshaymankar
requested changes
Aug 27, 2026
akshaymankar
left a comment
Member
There was a problem hiding this comment.
Do the expired codes somehow automatically get cleaned up from postgres? I couldn't see anything like that. Perhaps we should run a scheduled job to clean them up nightly or something.
Comment on lines
+12
to
+14
| -- index for lookups like `WHERE key = ? AND expires_at > now()` | ||
| CREATE INDEX activation_keys_key_expires_at_idx | ||
| ON activation_keys (key, expires_at); |
Member
There was a problem hiding this comment.
Why is this index needed if key is already the primary key?
Add Postgres, DualWrite, and Migration interpreters for the ActivationCodeStore effect (brig service). The migration follows the canonical dual-write + background-worker pattern: - Layer A: PostgresMarshall instances for ActivationKey/ActivationCode - Layer B: Postgres interpreter with TTL鈫抏xpires_at conversion - Layer C: DualWrite interpreter (reads鈫扖assandra, writes鈫抌oth) - Layer D: Migration loop copying ttl(code)鈫抏xpires_at - Layer E: activationKeys StorageLocation config field - Layer F: Brig interpreter selection + second-writer refactor - Layer G-H: Background-worker migration wrapper + flag - Layer I-R: SQL migration, helm values, config docs, integration test The key design decision: the second writer (Brig.Data.Activation.verifyCode) that bypassed the effect is now routed through a new VerifyActivationCode effect constructor. This preserves the brute-force protection (3 max retries, TTL-preserving countdown, delete on exhaustion) while allowing each interpreter to implement it natively. ActivationCodeStore was moved before the Error block in BrigLowerLevelEffects to ensure Error Hasql.UsageError is available when the Postgres interpreter runs. Bead: ws-migrate-postgresql-ec0
blackheaven
force-pushed
the
gdifolco/WPB-22970-migration-postgres-activation-keys
branch
from
August 27, 2026 14:05
a8abee9 to
b065da8
Compare
blackheaven
force-pushed
the
gdifolco/WPB-22970-migration-postgres-activation-keys
branch
2 times, most recently
from
August 27, 2026 16:53
4cebe09 to
ad3611f
Compare
- rename activation_keys column "user" -> user_id and drop the redundant (key, expires_at) index (PK on key serves the lookup); regenerate postgres-schema.sql - move verification logic out of the ActivationCodeStore effect into a new Wire.ActivationCodeVerificationStore effect over the store; the store keeps persistence only (LookupActivationKey / DecrementActivationRetries / DeleteActivationKey) - add a nightly Arbiter cron job (activation-keys queue) that deletes expired activation key rows from Postgres in bounded batches; new required config background-worker.config.activationKeysCleanup.schedule (default 0 3 * * *) - rewrite the integration test to drive the full lifecycle cassandra -> dual-write -> dual-write+worker -> postgresql, including retry convergence and brute-force exhaustion
blackheaven
force-pushed
the
gdifolco/WPB-22970-migration-postgres-activation-keys
branch
from
August 27, 2026 17:10
ad3611f to
9169072
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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-22970
Checklist
changelog.d