Created
November 3, 2020 22:01
-
-
Save dasl-/925a38a1a9516b6cb22f0c8f58013aaf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/go/vt/vttablet/tabletserver/tx_pool.go b/go/vt/vttablet/tabletserver/tx_pool.go | |
index e7ecfcc51..2e24c87be 100644 | |
--- a/go/vt/vttablet/tabletserver/tx_pool.go | |
+++ b/go/vt/vttablet/tabletserver/tx_pool.go | |
@@ -430,6 +430,7 @@ type TxConnection struct { | |
ImmediateCallerID *querypb.VTGateCallerID | |
EffectiveCallerID *vtrpcpb.CallerID | |
Autocommit bool | |
+ concludeMu sync.Mutex | |
} | |
func newTxConnection(conn *connpool.DBConn, transactionID int64, pool *TxPool, immediate *querypb.VTGateCallerID, effective *vtrpcpb.CallerID, autocommit bool) *TxConnection { | |
@@ -491,6 +492,13 @@ func (txc *TxConnection) RecordQuery(query string) { | |
} | |
func (txc *TxConnection) conclude(conclusion, reason string) { | |
+ txc.concludeMu.Lock() | |
+ defer txc.concludeMu.Unlock() | |
+ if (txc.DBConn == nil) { | |
+ // Another process already concluded this connection. Bail to avoid a go panic. | |
+ return | |
+ } | |
+ | |
txc.pool.activePool.Unregister(txc.TransactionID, reason) | |
txc.DBConn.Recycle() | |
txc.DBConn = nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment