From 4df91b3ab9bb1c5af4befce19d7b462e8b5dff02 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 e7bc825cb36f3..1307feba252c8 100644 --- a/pkg/sessionctx/variable/session.go +++ b/pkg/sessionctx/variable/session.go @@ -3553,8 +3553,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) }