Skip to content

UserStore: Add migration logic and migration interpreter - #5324

Draft
akshaymankar wants to merge 31 commits into
developfrom
user-pg-migration-code
Draft

UserStore: Add migration logic and migration interpreter#5324
akshaymankar wants to merge 31 commits into
developfrom
user-pg-migration-code

Conversation

@akshaymankar

Copy link
Copy Markdown
Member

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 Jul 7, 2026
@akshaymankar
akshaymankar force-pushed the user-pg-migration-code branch from 3e94d0b to 4dcb50c Compare July 9, 2026 12:35
@akshaymankar
akshaymankar force-pushed the user-pg-migration-code branch 6 times, most recently from c109be7 to acf0807 Compare August 3, 2026 09:25
@akshaymankar
akshaymankar force-pushed the user-pg-migration-code branch 2 times, most recently from 51dd43c to 1f3a077 Compare August 4, 2026 15:05
Comment thread integration/test/Test/Migration/User.hs
Comment thread integration/test/Test/Migration/User.hs Outdated
Comment thread integration/test/Test/Migration/User.hs
Comment thread integration/test/Test/Migration/Util.hs
Comment thread services/brig/src/Brig/Data/Activation.hs Outdated
Comment thread services/brig/src/Brig/Data/Activation.hs Outdated
Comment thread libs/wire-subsystems/src/Wire/UserStore/Cassandra.hs Outdated
Comment thread integration/test/Test/Migration/User.hs Outdated
mkUserRowPG id_ cass@UserRowCass {..} isHandleClaimed richInfo = run . runError $ do
pgName <- note UserHasNoName cass.name
pgActivated <- note UserHasNoActivated cass.activated
createdAt <- note UserHasNoActivated $ writetimeToUTC <$> cass.activatedWriteTime

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.

Something is odd here, IIRC activatedWriteTime is the last write time.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Its the write time of the activated field, I think its only gets written when the user is activated, which is what we can use as an approximation for when the user was created.

Comment thread libs/wire-subsystems/src/Wire/UserStore/Migration.hs
Comment thread services/brig/src/Brig/Schema/V93_ReduceUserGCGracePeriod.hs Outdated
Comment thread libs/wire-subsystems/src/Wire/UserStore/Migration.hs
) =>
Duration -> Prometheus.Counter -> Prometheus.Vector Text Prometheus.Histogram -> UserId -> Sem r ()
migrateUser migTimeout migCounter migDuration uid =
withExclusiveMigrationLockAndTimeout migTimeout migDuration [uid] $ do

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.

Is it fine to have a global lock?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

What do you mean global?

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.

For all users instead of one by one.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The migration is happening for one user at a time, so I think it makes sense for the lock to be for that user.

@akshaymankar
akshaymankar force-pushed the user-pg-migration-code branch from 06b20b3 to bb68426 Compare August 19, 2026 10:43
@akshaymankar
akshaymankar force-pushed the user-pg-migration-code branch from bb68426 to 150c8b9 Compare August 20, 2026 08:58
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