From 12b942112e1eaab107eae477295ff7ccf850aff6 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Thu, 5 Dec 2024 10:22:14 +0800 Subject: [PATCH] *: avoid unlock of unlocked mutex panic on TableDeltaMap (#57799) close pingcap/tidb#57798 --- pkg/sessionctx/variable/session.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/sessionctx/variable/session.go b/pkg/sessionctx/variable/session.go index 833e846a05c38..0551e777188c8 100644 --- a/pkg/sessionctx/variable/session.go +++ b/pkg/sessionctx/variable/session.go @@ -3778,8 +3778,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) }