Documents stopped replicating to CouchbaseLite from SyncGateway after CBLite encounters this error "E/CouchbaseLite/DATABASE:Assertion failed: .."

I suddenly saw documents stopped flowing to CBLite DB from SyncGateway, Then I checked the logs and found the below error.
2024-04-22 00:00:55,726 ERROR [stderr] (CBL#1) E/CouchbaseLite/DATABASE:Assertion failed: !_inTransaction (/home/couchbase/jenkins/workspace/couchbase-lite-core-linux/couchbase-lite-core/LiteCore/Storage/DataFile.cc:315, in beginTransactionScope)
2024-04-22 00:00:55,732 ERROR [stderr] (CBL#1) /tmp/com.couchbase.lite.java/native/edc465e4771f6e83343e528fd8d20ab2/libLiteCore.so(+0x874a0) [0x7f7a894f44a0]
2024-04-22 00:00:55,732 ERROR [stderr] (CBL#1) /tmp/com.couchbase.lite.java/native/edc465e4771f6e83343e528fd8d20ab2/libLiteCore.so(+0x875be) [0x7f7a894f45be]
2024-04-22 00:00:55,732 ERROR [stderr] (CBL#1) /tmp/com.couchbase.lite.java/native/edc465e4771f6e83343e528fd8d20ab2/libLiteCore.so(+0x4c1bc) [0x7f7a894b91bc]
2024-04-22 00:00:55,732 ERROR [stderr] (CBL#1) /tmp/com.couchbase.lite.java/native/edc465e4771f6e83343e528fd8d20ab2/libLiteCore.so(+0x15f01c) [0x7f7a895cc01c]
2024-04-22 00:00:55,732 ERROR [stderr] (CBL#1) 4 /tmp/com.couchbase.lite.java/native/edc465e4771f6e83343e528fd8d20ab2/libLiteCore.so c4db_beginTransaction + 42
2024-04-22 00:00:55,732 ERROR [stderr] (CBL#1) 5 /tmp/com.couchbase.lite.java/native/edc465e4771f6e83343e528fd8d20ab2/libLiteCore.so c4db_purgeExpiredDocs + 16
2024-04-22 00:00:55,732 ERROR [stderr] (CBL#1) 6 /tmp/com.couchbase.lite.java/native/edc465e4771f6e83343e528fd8d20ab2/libLiteCoreJNI.so Java_com_couchbase_lite_internal_core_C4Database_purgeExpiredDocs + 36
2024-04-22 00:00:55,732 ERROR [stderr] (CBL#1) [0x7f7ac9018507]
2024-04-22 00:00:55,735 ERROR [stderr] (CBL#1) Exception in thread “CBL#1” java.lang.Error: LiteCoreException{domain=1, code=1, msg=assertion failed}
2024-04-22 00:00:55,735 ERROR [stderr] (CBL#1) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1155)
2024-04-22 00:00:55,735 ERROR [stderr] (CBL#1) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
2024-04-22 00:00:55,735 ERROR [stderr] (CBL#1) at java.lang.Thread.run(Thread.java:748)
2024-04-22 00:00:55,735 ERROR [stderr] (CBL#1) Caused by: LiteCoreException{domain=1, code=1, msg=assertion failed}
2024-04-22 00:00:55,735 ERROR [stderr] (CBL#1) at com.couchbase.lite.LiteCoreException.throwException(LiteCoreException.java:26)
2024-04-22 00:00:55,735 ERROR [stderr] (CBL#1) at com.couchbase.lite.internal.core.C4Database.purgeExpiredDocs(Native Method)
2024-04-22 00:00:55,735 ERROR [stderr] (CBL#1) at com.couchbase.lite.internal.core.C4Database.purgeExpiredDocs(C4Database.java:103)
2024-04-22 00:00:55,735 ERROR [stderr] (CBL#1) at com.couchbase.lite.DocumentExpirationStrategy.purgeExpiredDocuments(DocumentExpirationStrategy.java:85)
2024-04-22 00:00:55,735 ERROR [stderr] (CBL#1) at com.couchbase.lite.internal.AbstractExecutionService$InstrumentedTask.run(AbstractExecutionService.java:94)
2024-04-22 00:00:55,735 ERROR [stderr] (CBL#1) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
2024-04-22 00:00:55,735 ERROR [stderr] (CBL#1) … 2 more

I am not able to understand why this error occuring and how to fix it? it would be great if you could pour some inputs on this.
CBLite SDK: Java
CBLite version: couchbase-lite-java-ee.2.7.0-94.jar

Thanks,
Lishakar J

CBLite version: couchbase-lite-java-ee.2.7.0-94.jar

The first step would be to upgrade to the latest version.

This is what I find in a very old (2019) DataFile.cc

The line number is off by one. It may be due to #pragmas. The error is that beginTransactionScope is being called while not in a transaction. But that’s really all I have to offers. someone from CBL will need to weigh-in.

313:    void DataFile::beginTransactionScope(Transaction* t) {
314:       Assert(!_inTransaction);
315:        checkOpen();
316:       _shared->setTransaction(t);
317:        _inTransaction = true;
318:    }
1 Like

Yeah… @mreiche has it exactly right:

  • CBL v2.7 has been EoL for nearly a year now. Time to update!
  • The mechanism for purging expired documents did have a bug. It has been fixed in subsequent releases.
1 Like