Skip to content

fix(account): resolve the active user deterministically when picking which duplicate to keep - #6595

Merged
mahibi merged 1 commit into
masterfrom
improveScheduleDuplicateAccountsForDeletion
Aug 27, 2026
Merged

fix(account): resolve the active user deterministically when picking which duplicate to keep#6595
mahibi merged 1 commit into
masterfrom
improveScheduleDuplicateAccountsForDeletion

Conversation

@mahibi

@mahibi mahibi commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

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.

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔖 Capability is checked or not needed
  • 🔙 Backport requests are created or not needed: /backport to stable-xx.x
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@mahibi mahibi added this to the 25.1.0 milestone Aug 27, 2026
@mahibi mahibi self-assigned this Aug 27, 2026
…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>
@mahibi
mahibi force-pushed the improveScheduleDuplicateAccountsForDeletion branch from f1a311d to f4157de Compare August 27, 2026 10:00
@github-actions

Copy link
Copy Markdown
Contributor

APK file: https://github.com/nextcloud/talk-android/actions/runs/33061103029/artifacts/9644884231
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.
qrcode (please click on link to get QR code displayed)

@mahibi
mahibi marked this pull request as ready for review August 27, 2026 15:01
@mahibi
mahibi merged commit 5fab306 into master Aug 27, 2026
18 of 21 checks passed
@mahibi
mahibi deleted the improveScheduleDuplicateAccountsForDeletion branch August 27, 2026 17:46
@mahibi

mahibi commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

/backport to stable-25.0.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant