Repository navigation
fix: check answers for a database that a crash left with a hot journal - #28
Merged
Merged
Conversation
SQLite refuses to read a database with a hot rollback journal through a read-only connection (SQLITE_READONLY_ROLLBACK), so Sealite.check threw an SQLiteException for every key after a crash in the middle of a write or of a rekey, which is the very situation the documented key-storage protocol calls it in. It now reopens read-write in that one case, which rolls the unfinished transaction back as any later open would, and then answers.
When the cache directory can not be trusted the library is extracted to a new temporary directory. Only the directory was registered for deletion, and a directory that still holds the library is not removed, so every start left a copy of the library behind.
…update the readme version
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.
What and why
Each fix is proven by a test that failed on
main:Sealite.checkanswered nothing after a crash in the middle of a write. A hot-journalmakes SQLite refuse to read the database through a read-only connection (SQLITE_READONLY_ROLLBACK, 776).checkthrew anSQLiteExceptionfor every key. That is exactly the situation step 4 of the documented key-storage protocol after arekeycalls it in. In that one case it now reopens read-write. SQLite rolls the unfinished transaction back, as the next open by anyone would, andcheckanswers for the rolled-back file. A wrong key still answersWrongKey: HMAC verification fails before anything is written. The test checks the wrong key first, then the right one, thenintegrity_checkand the committed rows. KDoc, README and Module.md no longer saychecknever writes.extra-files), so a release updates its version. This is in its own commit,bdbc1a1, and can be dropped.How it was tested
CheckTest.aDatabaseACrashLeftWithAHotJournalIsAnsweredForBothKeysAndRolledBack(JVM and macOS native),LoaderExitTest(child JVM, POSIX),OpenSequenceTest.aMessageReportsExactlyItsOwnCode:sealite:jvmTest, the threejvmLoaderEnvTest*tasks,:sealite:macosArm64Test,koverVerify(100 %),detekt,checkLegacyAbi,dokkaGeneratePublicationHtml,spotlessCheckNot verified: Android, iOS, Windows and Linux. This PR's CI runs them.
Checklist
sealite/apidumps identical)Stringor left unwipedCHANGELOG-relevant behaviour described above