Application crashes with "UNIQUE constraint failed: thread.recipient_id" after adding new contact
- [x] I have searched open and closed issues for duplicates
- [x] I am submitting a bug report for existing functionality that does not work as intended
- [x] I have read https://github.com/signalapp/Signal-Android/wiki/Submitting-useful-bug-reports
- [x] This isn't a feature request or a discussion topic
Bug description
Signal keeps crashing whenever I attempt to start it.
Steps to reproduce
I'm not 100% sure of what happened but here is what I did today:
-
At one point during the day, I added a new contact
-
I sent them a message request from Signal
-
I never received their reply
-
Signal kept notifying me with "You may have new messages" but I wasn't receiving anything
-
I was still able to send messages to other contacts and they contacts received them
-
I eventually opened signal-desktop and saw a lot of messages there, I also saw whatever I sent from my phone
-
I attempted to force Signal to stop on my phone, I also attempted to clear its cache
-
I eventually rebooted my phone
-
Since the reboot, Signal keeps crashing a fraction of second after I open it
-
A few seconds before crashing, it would show the new contact as "Unknown" instead of their name. Here is a screenshot showing this and the message I sent them to initiate the conversation ("Test"):
-
I attempted to archive the conversation in the fraction of seconds I had before the app crashed but it did not help
Device info
Device: Google Pixel 6a Android version: 14 Signal version: 6.46.7
Link to debug log
I can't provide this because of the crash. However, I can provide an excerpt of what I gathered via adb, this is the whole log for the crashing thread: thread.23513.log.txt. I can provide the log for all threads via email, I don't want to attach it publicly.
The relevant parts seem to be:
02-13 23:39:22.838 23463 23513 W ThreadTable: Merging threads. Primary: RecipientId::340, Secondary: RecipientId::339
02-13 23:39:22.839 23463 23513 W ThreadTable: [merge] Only had a thread for secondary. Updating it to have the recipientId of the primary.
02-13 23:39:22.840 23463 23513 E BaseJob : Encountered a fatal exception. Crash imminent.
02-13 23:39:22.840 23463 23513 E BaseJob : android.database.sqlite.SQLiteConstraintException: FullCode: 2067 | ErrorCode: 19 | ExtendedErrorCode: 8 | Message: UNIQUE constraint failed: thread.recipient_id | ExtraMessage: null
Hi,
I'm facing the same issue. I also recently added a new contact and now can only send but not receive any messages on my phone. Signal Desktop works fine.
However, the app doesn't crash for me. If the full debug logs as extracted from within the app are of any help, you can find them here:
- Signal 6.46.7: https://debuglogs.org/android/6.46.7/820e58967c2a9565898c9ed5ca34233d5a767388be71c93d1ebde99e9f460ba5
- Signal 6.47.2: https://debuglogs.org/android/6.47.2/301f7978d374a206b2a4d42ffd6e50eb5faf0069c4606bf20b400f0fcb32ecdb
Device info
Device: Google Pixel 6 Pro Android version: 14 (security patches 05 February 2024) Signal version: 6.47.2
If you need any further information, I'm happy to help.
In case this helps other people hitting the bug, I might have found a workaround, here is what I did:
- Turned on aeroplane mode
- Started Signal, it was not crashing any more!
- Checked "Archived conversations" at the end of the chat list because I had attempted to archive the broken conversation with the new contact
- Deleted the "Unknown" conversation
- Restored network access
This fixed Signal which retrieved all the missing messages. I might be wrong but I think the crash happened when Signal was attempting to retrieve messages sent to me by the new contact. I did receive them (as a new conversation) after deleting the broken conversation.
All credit goes to another issue (#13198) related to UNIQUE constraint failed where I found this very useful comment:
Signal crashes on opening. Note: this doesn’t happen in airplane mode
One thing I learnt from this: without root access, it's pretty hard to access Signal's database. I wanted to check the duplicate rows myself but it seems very difficult. I couldn't get root without unlocking the firmware (which apparently meant deleting all data on the phone). The other option was adb run-as which would have required installing a debuggable Signal build, the hard part being building it myself (because I couldn't find such a build online).
Thanks a lot, deleting the unknown conversation solved the issue for me :)
This should also be fixed in the latest versions but appreciate y'all helping each other out in the meantime.
@cody-signal thanks for the fix, may I ask what introduced this bug? Was it a recent regression? And what fixed it? Was it 3c6c03cd7566753604970bd31c5d7c9e7eae9b24?
Not recent per se, just rare conditions.
Should be fixed by: https://github.com/signalapp/Signal-Android/commit/ba41df19bbf80dd8b33ff1e7efa2142234eaf8f7
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.