Details
Description
This is reported by CBSE-14300.
Platform: CBL-C 3.0.11 running on Android / iOS via Flutter plugin.
Summary of Scenarios:
1. Replicator connecting to SG is started.
2. SG responded with a session cookie to be saved into the cookie storage.
3. At the same time, the application saved documents into the database.
4. The application received the error as follows:
LiteCore throwing LiteCore error 17: must be called during a transaction |
From the customer logs and analysis, the issue happened after the Replicator's BuiltInWebSocket caught the !_inTransaction (DataFile.cc:356, in beginTransactionScope) assertion failure while connecting to SG as the log below:
2023-04-24 18:45:14.415045| [error] ERROR: Assertion failed: !_inTransaction (DataFile.cc:356, in beginTransactionScope) *******************************2023-04-24 18:45:14.426974| [error] [WS] ERROR: {135|BuiltInWebSocket} caught exception while connecting: Assertion failed: !_inTransaction *******************************2023-04-24 18:45:14.427816| [info] [Sync]: {134} Connection closed with Unknown error 1: "Assertion failed: !_inTransaction" (state=1) *******************************2023-04-24 18:45:14.428246| [error] [Sync] ERROR: {134|Repl} Got LiteCore error: LiteCore RemoteError, "Assertion failed: !_inTransaction" *******************************2023-04-24 18:45:14.428312| [error] [Sync] ERROR: {65|C4Replicator} State: connecting, progress=0%, error=LiteCore RemoteError, "Assertion failed: !_inTransaction" *******************************2023-04-24 18:45:14.437224| [error] [Sync] ERROR: {65} State: stopped, progress=0%, error=LiteCore RemoteError, "Assertion failed: !_inTransaction" ******************************* |
The only thing that is touching the database during the connecting state is saving the cookies and the customer have found that the code that saves the cookies into the database is called without locking:
After the assertion failure from the BuiltInWebSocket, a series of errors from saving documents occurred :
2023-04-24 18:49:57.078966| [error] ERROR: LiteCore throwing LiteCore error 17: must be called during a transaction |
2023-04-24 18:51:56.339561| [error] ERROR: LiteCore throwing LiteCore error 17: must be called during a transaction |
2023-04-24 18:51:58.686432| [error] ERROR: LiteCore throwing LiteCore error 17: must be called during a transaction |
2023-04-24 18:52:28.938408| [error] ERROR: LiteCore throwing LiteCore error 17: must be called during a transaction |
From the code point of view, that happened because after the assertion failure, theĀ ExclusiveTransaction object will be destructed which will end the transaction with the _inTransaction flag reset.
Please find full logs and more description from the CBSE ticket.
Attachments
Issue Links
- backports to
-
CBL-4529 Error when saving documents with LiteCore error 17: must be called during a transaction
-
- Closed
-
-
CBL-4535 Error when saving documents with LiteCore error 17: must be called during a transaction
-
- Closed
-
- Clones
-
CBL-4529 Error when saving documents with LiteCore error 17: must be called during a transaction
-
- Closed
-