Skip to content

Fix UNIQUE constraint on storage_service_id during backup and transfer - #14973

Open
loucass wants to merge 17 commits into
signalapp:mainfrom
loucass:fix/android-backup-transfer-storageid
Open

loucass wants to merge 17 commits into
signalapp:mainfrom
loucass:fix/android-backup-transfer-storageid

Conversation

@loucass

@loucass loucass commented Aug 30, 2026

Copy link
Copy Markdown

Fixes #14954

Enabling backups during device transfer could hit UNIQUE constraint on recipient.storage_service_id (2067) and loop. Group import generated a random key without retry, so collision crashed the flow. Retry with new key up to 5 times and skip on persistent collision.

@loucass
loucass force-pushed the fix/android-backup-transfer-storageid branch from 9372adb to 48eca2e Compare August 30, 2026 18:38
@loucass
loucass marked this pull request as draft September 1, 2026 13:59
@loucass
loucass marked this pull request as ready for review September 1, 2026 14:26
@loucass
loucass force-pushed the fix/android-backup-transfer-storageid branch from c4252cc to 425c8dd Compare September 1, 2026 15:07
@loucass

loucass commented Sep 5, 2026

Copy link
Copy Markdown
Author

Small update on this one. I dug into the actual crash log and the failure is an UPDATE on the self account row, so I centered the fix there:
1- free that id inside the transaction
2- update self id to this id
3- then move the other row to a checked fresh id
If that ever fails, the row keeps a NULL id and the next sync repairs it by itself.

Also in this push:

  • Restoring a group that already exists just reuses it now.
  • A failed group no longer poisons later steps with a fake id.
  • Inserts retry both ways a duplicate can surface, max 5 tries, then fail
    loud with an internal report instead of looping forever.

Added tests for all three in RecipientTableTest — green here:
https://github.com/loucass/Signal-Android/actions/runs/33978175898

Happy to adjust anything to match how you'd like it done.

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

Labels

None yet

Projects

None yet

1 participant