Skip to content

[stable-25.0.x] avoid FK constraint exceptions - #6599

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

[stable-25.0.x] avoid FK constraint exceptions#6599
mahibi merged 1 commit into
stable-25.0.xfrom
backport/6593/stable-25.0.x

Conversation

@backportbot

@backportbot backportbot Bot commented Aug 27, 2026

Copy link
Copy Markdown

Backport of PR #6593

Exception android.database.sqlite.SQLiteConstraintException: FOREIGN KEY constraint failed (code 787)
  at net.zetetic.database.sqlcipher.SQLiteConnection.nativeExecute
  at net.zetetic.database.sqlcipher.SQLiteConnection.execute (SQLiteConnection.java:592)
  at net.zetetic.database.sqlcipher.SQLiteSession.execute (SQLiteSession.java:624)
  at net.zetetic.database.sqlcipher.SQLiteStatement.execute (SQLiteStatement.java:70)
  at androidx.sqlite.driver.SupportSQLiteStatement$OtherSQLiteStatement.step (SupportSQLiteStatement.android.kt:540)
  at androidx.room.EntityInsertAdapter.insert (EntityInsertAdapter.kt:59)
  at com.nextcloud.talk.data.database.dao.ConversationsDao_Impl.insertConversation$lambda$0 (ConversationsDao_Impl.kt:336)
  at com.nextcloud.talk.data.database.dao.ConversationsDao_Impl$$ExternalSyntheticLambda5.invoke (D8$$SyntheticClass)
  at androidx.room.util.DBUtil__DBUtil_androidKt$performBlocking$1$1$invokeSuspend$$inlined$internalPerform$1.invokeSuspend (DBUtil.kt:173)
  at androidx.room.util.DBUtil__DBUtil_androidKt$performBlocking$1$1$invokeSuspend$$inlined$internalPerform$1.invoke (DBUtil.kt:8)
  at androidx.room.util.DBUtil__DBUtil_androidKt$performBlocking$1$1$invokeSuspend$$inlined$internalPerform$1.invoke (DBUtil.kt:4)
  at androidx.room.coroutines.PassthroughConnectionPool$useConnection$2.invokeSuspend (PassthroughConnectionPool.kt:59)
  at androidx.room.coroutines.PassthroughConnectionPool$useConnection$2.invoke (PassthroughConnectionPool.kt:8)
  at androidx.room.coroutines.PassthroughConnectionPool$useConnection$2.invoke (PassthroughConnectionPool.kt:4)

This could happen when a account was deleted and chat sync is in progress at the same time.

This might be a side effect of duplicated accounts.
See https://github.com/nextcloud/talk-android/pull/6559/files which might even trigger the FK constraint more often by deleting duplicated accounts.

The conversation (and cascaded via its account removal) may have been deleted
between persisting chatMessageEntities above and this chat block write, tripping
the ChatBlocks.internalConversationId foreign key. The block is now moot.

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
@backportbot
backportbot Bot requested review from mahibi and rapterjet2004 August 27, 2026 15:50
@backportbot backportbot Bot added the 3. to review Waiting for reviews label Aug 27, 2026
@backportbot backportbot Bot added this to the 25.0.0 milestone Aug 27, 2026
@mahibi
mahibi merged commit 6e752e5 into stable-25.0.x Aug 27, 2026
10 of 15 checks passed
@mahibi
mahibi deleted the backport/6593/stable-25.0.x branch August 27, 2026 15:54
@github-actions

Copy link
Copy Markdown
Contributor

APK file: https://github.com/nextcloud/talk-android/actions/runs/33090025865/artifacts/9659524776
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)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant