From b1c22cfa07e7717e941fd4ccf626bccaf1862c9d Mon Sep 17 00:00:00 2001 From: Flowyi Date: Sat, 20 Jan 2024 11:04:47 +0800 Subject: [PATCH] Fix the panic message of MemQuota.Record (#10479) close pingcap/tiflow#10478 --- cdc/processor/memquota/mem_quota.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cdc/processor/memquota/mem_quota.go b/cdc/processor/memquota/mem_quota.go index 7586f63e345..729ce027c7d 100644 --- a/cdc/processor/memquota/mem_quota.go +++ b/cdc/processor/memquota/mem_quota.go @@ -172,9 +172,12 @@ func (m *MemQuota) Record(span tablepb.Span, resolved model.ResolvedTs, nBytes u // Can't find the table record, the table must be removed. usedBytes := m.usedBytes.Load() if usedBytes < nBytes { - log.Panic("MemQuota.refund fail", - zap.Uint64("used", usedBytes), zap.Uint64("refund", nBytes)) + log.Panic("MemQuota.record fail", + zap.Uint64("used", usedBytes), zap.Uint64("record", nBytes)) } + // If we cannot find the table, then the previous acquired memory quota needed to be returned. + // Note that "usedBytes.Add(^(nBytes - 1))" means "usedBytes.Sub(nBytes)". But atomic don't + // have Sub method. if m.usedBytes.Add(^(nBytes - 1)) < m.totalBytes { m.blockAcquireCond.Broadcast() }