Skip to content

[stable-25.0.x] fix(account): resolve the active user deterministically when picking which duplicate to keep - #6606

Merged
mahibi merged 1 commit into
stable-25.0.xfrom
backport/6595/stable-25.0.x
Aug 27, 2026
Merged

[stable-25.0.x] fix(account): resolve the active user deterministically when picking which duplicate to keep#6606
mahibi merged 1 commit into
stable-25.0.xfrom
backport/6595/stable-25.0.x

Conversation

@backportbot

@backportbot backportbot Bot commented Aug 27, 2026

Copy link
Copy Markdown

Backport of PR #6595

…which duplicate to keep

scheduleDuplicateAccountsForDeletion() picked a duplicate to keep via an
unordered current=1 lookup, which can disagree with whichever row a live
session/background sync is actually bound to if a past bug left more than
one row marked current=true for the same account. Deleting that row then
trips a foreign key constraint on any in-flight write still referencing it.

Make getActiveUser()/getActiveUserObservable()/getActiveUserSynchronously()
deterministic via ORDER BY id DESC LIMIT 1, and have
scheduleDuplicateAccountsForDeletion() prefer whichever row that resolves
to over the current flag.

Assisted-by: Claude:claude-sonnet-5

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
@backportbot
backportbot Bot requested a review from mahibi August 27, 2026 17:48
@backportbot backportbot Bot added 3. to review Waiting for reviews AI assisted labels Aug 27, 2026
@backportbot backportbot Bot added this to the 25.0.0 milestone Aug 27, 2026
@mahibi
mahibi merged commit e074727 into stable-25.0.x Aug 27, 2026
11 of 15 checks passed
@mahibi
mahibi deleted the backport/6595/stable-25.0.x branch August 27, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews AI assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant