CS-2286 Fix SQLite write ahead logging checkpoint corruption on M1#2
Open
ValeriyLapin wants to merge 1 commit intorelease/1.4.2-amcofrom
Open
CS-2286 Fix SQLite write ahead logging checkpoint corruption on M1#2ValeriyLapin wants to merge 1 commit intorelease/1.4.2-amcofrom
ValeriyLapin wants to merge 1 commit intorelease/1.4.2-amcofrom
Conversation
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.
Addresses issue: CS-2286
Expectations
This PR fixes SQLite database corruption during compaction on M1 Macs. Two changes in
CBL_SQLiteStorage.m:sqlite3_busy_timeout(dbHandle, 5000)- gives SQLite 5 seconds to resolve internal lock contention between the app's main connection and the background replicator thread, instead of immediately failing withSQLITE_BUSYPRAGMA wal_checkpoint(PASSIVE)- replacesRESTARTmode which required exclusive database access.PASSIVEcheckpoints only what it can without blocking other threads, eliminating the race condition that caused corruption when the replicator was writing concurrentlyReview
Source/CBL_SQLiteStorage.mline 235 - verifysqlite3_busy_timeoutis called right after obtainingdbHandleSource/CBL_SQLiteStorage.mline 2212 - verifywal_checkpointusesPASSIVEinstead ofRESTARTTests
No new unit tests added.