Repository navigation
Conversation
johnw188
force-pushed
the
fix-keyvalue-partial-recovery
branch
from
November 9, 2026 18:54
0955769 to
82f2809
Compare
johnw188
force-pushed
the
fix-keyvalue-partial-recovery
branch
from
November 9, 2026 20:05
82f2809 to
63131a1
Compare
3 tasks done
On a corrupted database, the transactions used by the integrity check can fail even when the check itself runs. For example, after `PRAGMA quick_check` reads a page whose SQLCipher HMAC doesn't match, COMMIT fails with "SQL logic error". `read` and `write` owsFail on any error, so tapping "Continue" on the database recovery screen crashed before recovery could start. Use the throwing variants, as `DatabaseRecovery.reindex` already does. If a check ran, use its result even if ending the transaction failed; if it couldn't run, treat it as failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When copying a table hit a corrupted page, two things went wrong: - Iteration stopped, so every row after the page was lost. - Ending the read transaction also failed, and copyTable reported a total failure, even though the rows it copied were already committed to the new database. For tables with rowids, copy in rowid order and, after a read error, search for the next readable rowid and continue from there. Stop a pass if rowids go backwards, which a corrupted b-tree can cause, so rows are never copied twice. Report the rows copied even if ending the read fails, and prefer reporting SQLITE_FULL, since the user can fix that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
johnw188
force-pushed
the
fix-keyvalue-partial-recovery
branch
from
November 9, 2026 22:10
63131a1 to
138aa43
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contributor checklist
Administrative:
Testing:
main.Commits:
main.Human Note
I (@johnw188) took on this work to help a friend whose Signal database on their phone is showing as corrupted. I found the referenced issue #5811 where other users had had similar issues. On investigation I found that one corrupted page in
keyvaluefails the entire repair, and I believe that most users would rather have all but one of their messages than be stuck with no history.This PR was built with Opus 5.5, extensively reviewed by models, and then reviewed by me as a final check. I'm not familiar with the Signal codebase, so while the changes look correct to me. I would want someone with context to review before merging.
Opus 5.5 output below
Description
Fixes part of #5811.
PRAGMA quick_checkcan fail ("SQL logic error").read/writeowsFail on that, so tapping "Continue" on the recovery screen crashed before recovery started. This commit uses the throwing variants, asreindexalready does. If a check ran, it keeps that result; if the check couldn't run, it treats it as failed.main, a row whose last overflow page is corrupted can be copied with a zero-filled tail.My friend's log shows recovery failing on a corrupted page in
keyvalue, which must be copied flawlessly. This PR doesn't change that. I've opened #6396 as a separate proposal, because it's a policy decision.Testing
The tests corrupt pages on disk, which breaks their SQLCipher HMAC. A helper checks that exactly the intended rows became unreadable.
testIntegrityCheckOnCorruptedDatabase: onmain, the test process crashes withFailing for unexpected throw: SQL logic error.testDumpAndRestoreSkipsCorrupted…: four cases onKeyTransparency, where only the corrupted rows are lost:On
main, everything after the first corrupted row is lost.testMoreActionableErrorPrefersRunningOutOfSpace.Each commit passes
DatabaseRecoveryTeston its own. The fullSignalServiceKitTestssuite passes.Screen recordings
To set up the recordings, a local launch hook (not included in this PR) filled
KeyTransparencyand corrupted one of its pages.Before (
main): Repair → Continue crashes.before-main.mp4
After (this branch): Repair → Continue ends at "Data Successfully Recovered".
after-fix.mp4
I haven't tested on a physical device.
🤖 Generated with Claude Code