From 815c1a5afbcdc67ca128836ca065dd0b7c845883 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 --- 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) }