From ae254cae5703809749ddd7056e50ff539856fd34 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Thu, 20 Feb 2025 15:31:43 +0800 Subject: [PATCH] *: avoid unlock of unlocked mutex panic on TableDeltaMap | tidb-test=920d9bf1b1137cda1272bdd59ae527aee8067944 (#57799) (#59666) close pingcap/tidb#57798 --- sessionctx/variable/session.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sessionctx/variable/session.go b/sessionctx/variable/session.go index c0318adf56a13..ea668826e089b 100644 --- a/sessionctx/variable/session.go +++ b/sessionctx/variable/session.go @@ -3181,8 +3181,9 @@ func (s *SessionVars) GetNegateStrMatchDefaultSelectivity() float64 { // GetRelatedTableForMDL gets the related table for metadata lock. func (s *SessionVars) GetRelatedTableForMDL() *sync.Map { - s.TxnCtx.tdmLock.Lock() - defer s.TxnCtx.tdmLock.Unlock() + mu := &s.TxnCtx.tdmLock + mu.Lock() + defer mu.Unlock() if s.TxnCtx.relatedTableForMDL == nil { s.TxnCtx.relatedTableForMDL = new(sync.Map) }