Write Write Conflict

Hi, getting exceptions when bulk insert inside transactions. Inserting only one document looks great but, the second and beyond fails. It’s occuring in some collections, and only when commit() is called. Any help welcome.

Caused by: com.couchbase.client.core.error.CouchbaseException: Unknown query error {"completed":true,"coreId":"0xc7aff92200000001","errors":[{"additional":{"cause":{"cause":{"bucket":"softchef-bucket","cause":"deadline expired before WWC was resolved on softchef-bucket._default._default._txn:atr-994-#9f","collection":"Turno","document_key":"1:1:15","msg":"write write conflict","scope":"pdv"},"raise":"failed","retry":true,"rollback":false}},"code":17007,"message":"Commit Transaction statement error"}],"httpStatus":200,"idempotent":false,"lastDispatchedFrom":"127.0.0.1:53295","lastDispatchedTo":"127.0.0.1:8093","requestId":4834,"requestType":"QueryRequest","retried":0,"service":{"operationId":"1bffffde-5032-4345-a119-75d91d5c9305","statement":"COMMIT","target":"NodeIdentifier{address=127.0.0.1, managerPort=8091}","type":"query"},"timeoutMs":85970307,"timings":{"dispatchMicros":1163500,"totalDispatchMicros":1163500,"totalMicros":1164459}}
	at com.couchbase.client.core.io.netty.query.QueryChunkResponseParser.errorsToThrowable(QueryChunkResponseParser.java:177)
	at com.couchbase.client.core.io.netty.query.QueryChunkResponseParser.lambda$new$8(QueryChunkResponseParser.java:106)
	at com.couchbase.client.core.json.stream.JsonStreamParser.emitCapturedValue(JsonStreamParser.java:213)
	at com.couchbase.client.core.json.stream.StructureNavigator.finishValue(StructureNavigator.java:285)
	at com.couchbase.client.core.json.stream.StructureNavigator.access$800(StructureNavigator.java:32)
	at com.couchbase.client.core.json.stream.StructureNavigator$FastForwarding.accept(StructureNavigator.java:276)
	at com.couchbase.client.core.json.stream.StructureNavigator$FastForwarding.accept(StructureNavigator.java:256)
	at com.couchbase.client.core.json.stream.StructureNavigator.accept(StructureNavigator.java:90)
	at com.couchbase.client.core.json.stream.JsonStreamParser.processTokens(JsonStreamParser.java:172)
	at com.couchbase.client.core.json.stream.JsonStreamParser.feed(JsonStreamParser.java:123)
	at com.couchbase.client.core.io.netty.chunk.BaseChunkResponseParser.feed(BaseChunkResponseParser.java:153)
	at com.couchbase.client.core.io.netty.chunk.ChunkedMessageHandler.handleHttpContent(ChunkedMessageHandler.java:257)

Hi @Alexandre_Camilo
Are you using the transactions library / SDK to perform this transaction? If not then I strongly recommend doing so. It will automatically take care of advanced error handling, including retrying the transaction where needed.

Here, it appears from the error message that a write-write conflict with another transaction was hit. Our algorithm for handling that is to block internally (inside query service) waiting for the blocking transaction to reach a completed state whereupon we can retry the write. And if that fails then the query returns an error and the transactions SDK (if that is in use) will retry.

Actually on rereading your problem description I see you mention a .commit(), suggesting you are using the transactions library. In which case can you please provide a transactions log following the guidance here?