From 1038068978546c432868ae827dade038e42750f6 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Sat, 8 Jan 2022 15:06:37 +0800 Subject: [PATCH] table/tables: avoid repeated renew lease operation for cached table (#31475) close pingcap/tidb#31474 --- table/tables/cache.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/table/tables/cache.go b/table/tables/cache.go index c4856fe52e98b..73d2f908fcda2 100644 --- a/table/tables/cache.go +++ b/table/tables/cache.go @@ -94,7 +94,12 @@ func (c *cachedTable) TryReadFromCache(ts uint64, leaseDuration time.Duration) k nowTime := oracle.GetTimeFromTS(ts) distance := leaseTime.Sub(nowTime) if distance >= 0 && distance <= leaseDuration/2 { - c.renewCh <- c.renewLease(ts, RenewReadLease, data, leaseDuration) + op := c.renewLease(ts, RenewReadLease, data, leaseDuration) + select { + case c.renewCh <- op: + default: + // Skip this time, if the previous renew lease operation hasn't finished. + } } return data.MemBuffer }