Details
Description
Failed Line:
https://github.com/couchbase/couchbase-lite-ios/blob/release/3.1/Objective-C/Tests/ReplicatorTest%2BMain.m#L813That line is trying to save a document after the replicator is stopped.
Log (Can't reproduce the issue when setting log level to verbose or debug):
https://gist.github.com/pasin/c2c27d55cfe8d09328c730845fece9f5
BT: https://gist.github.com/pasin/7dfe902fc7f5e789aacfcf2322cf781a
Analysis:
1. When stopping the replicator, the replicator will close its internal database (in the background thread).
2. In the process of closing the database, we also run "PRAGMA analysis_limit=400; PRAGMA optimize" so that the query plan could be updated.
3. The "PRAGMA analysis_limit=400; PRAGMA optimize" is expected to run very fast but it could be run a bit longer depending on data and number of indexes.
4. However, While running "PRAGMA analysis_limit=400; PRAGMA optimize", the SQLite database is locked. As a result, this could cause a side effect if on another thread, a write the the database (e.g. saving a document) happens, the write will be errored as the database is locked.
Attachments
Issue Links
- duplicates
-
CBL-4413 Compaction could cause "database is locked" error when the replicator attempts to save its checkpoint at the same time
- Closed
- is cloned by
-
CBL-4395 Stop replicator could cause 'database is locked' error when saving a document
- Closed
- relates to
-
CBL-4413 Compaction could cause "database is locked" error when the replicator attempts to save its checkpoint at the same time
- Closed