[GODRIVER-1812] Panic in Transaction Callback Results in Permanent Write Conflict Created: 16/Dec/20  Updated: 27/Oct/23  Resolved: 17/Dec/20

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: David Wen Riccardi-Zhu Assignee: Unassigned
Resolution: Gone away Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I've started to develop our first Transaction with the Go driver (v1.4.4) and an Atlas instance (v4.2.11). I'm quite new to using transactions, so apologies if what follows is not clear.

A panic in the function parameter for WithTransaction appears to have resulted in the session not closing. All subsequent transactions are now failing with a Write Conflict – despite the panic being fixed, and a half-hour passing since the panic.

Following is what I'm using for my transactions:

session, err := client.StartSession()
{{ if err != nil {}}
  panic(err)
{{ }}}
{{ defer session.EndSession(p.Ctx)}}

res, err := session.WithTransaction(p.Ctx, p.CB)
{{ if err != nil {}}
  return err
{{ }}}

 

The panic occurred in p.CB, above. I would have expected the deferred session.EndSession call to have been called regardless of the panic. But somehow, all subsequent transactions are returning a Write Conflict.

What happens if there is no timeout in the context? Does the session remain open indefinitely?



 Comments   
Comment by David Wen Riccardi-Zhu [ 16/Dec/20 ]

I think this can be closed – the issue was likely a concurrent update happening without the Session Context, and previously masked by a race condition.

Comment by David Wen Riccardi-Zhu [ 16/Dec/20 ]

I have attempted multiple failovers and pausing and restarting my cluster, but all transactions are still returning "Write Conflict".

If it's useful, this is what I see with db.serverStatus() for transactions:

{{{}}
{{ "retriedCommandsCount" : NumberLong(0),}}
{{ "retriedStatementsCount" : NumberLong(0),}}
{{ "transactionsCollectionWriteCount" : NumberLong(28),}}
{{ "currentActive" : NumberLong(0),}}
{{ "currentInactive" : NumberLong(0),}}
{{ "currentOpen" : NumberLong(0),}}
{{ "totalAborted" : NumberLong(2),}}
{{ "totalCommitted" : NumberLong(0),}}
{{ "totalStarted" : NumberLong(2),}}
{{ "totalPrepared" : NumberLong(0),}}
{{ "totalPreparedThenCommitted" : NumberLong(0),}}
{{ "totalPreparedThenAborted" : NumberLong(0),}}
{{ "currentPrepared" : NumberLong(0)}}
}

Generated at Thu Feb 08 08:37:11 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.