Skip to content

UserStore: Add migration logic and migration interpreter - #5324

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

UserStore: Add migration logic and migration interpreter#5324
akshaymankar wants to merge 24 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
newScimUser <-
if shouldCreateRichInfo
then
-- TODO: Actually generate rich info

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.

if it is intentional, I prefer FUTUREWORK

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.

I'll try to actually implement it before merging this, I'm not really done with making the tests more robust yet.

Comment thread integration/test/Test/Migration/User.hs
Comment thread integration/test/Test/Migration/Util.hs
Comment on lines +84 to +86
-- lift $ Log.warn $ Log.msg (Log.val "activation will be verified") . Log.field "key" (show k) . Log.field "code" (show c)
(emailKey, mUser) <- wrapClientE (verifyCode k c)
-- lift $ Log.warn $ Log.msg (Log.val "activation verified") . Log.field "key" (show k) . Log.field "code" (show c)

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.

Debug?

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.

Yeah this stuff needs to go, I'll clean it up before asking for next review.

unless (userStatus a == Active) $ do
lift $
Log.warn $
Log.msg (Log.val "-------> User is not active")

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.

Can you use a more formal message?

import Polysemy.Resource (Resource)
import Polysemy.Time
import Polysemy.TinyLog (TinyLog, warn)
import System.Logger.Message qualified as Log

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 used?

Comment on lines +247 to +248
scimUsersWithRichInfo <- Concurrently $ createScimUsers domain n True True
scimUsersWithoutRichInfo <- Concurrently $ createScimUsers domain n True True

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.

Shouldn't bools be different?

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.

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.

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