Skip to content

Commit

Permalink
table/tables: avoid repeated renew lease operation for cached table (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancaiamao authored and pull[bot] committed Feb 22, 2024
1 parent 5143102 commit 1038068
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion table/tables/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 1038068

Please sign in to comment.