From 0e4e8c9d3a7247e528ccbbcfeebc5655541c1010 Mon Sep 17 00:00:00 2001 From: disksing Date: Wed, 27 Sep 2017 20:34:20 +0800 Subject: [PATCH] store/tikv: fix gc bug. (#4665) --- store/tikv/gc_worker.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/store/tikv/gc_worker.go b/store/tikv/gc_worker.go index 581d265eaa..32de746bb9 100644 --- a/store/tikv/gc_worker.go +++ b/store/tikv/gc_worker.go @@ -588,18 +588,9 @@ func doGC(ctx goctx.Context, store *tikvStore, safePoint uint64, identifier stri gcWorkerCounter.WithLabelValues("do_gc").Inc() store.gcWorker.saveSafePoint(gcSavedSafePoint, safePoint) - // We want to make sure to delay enough time even if the Sleep is disrupted - { - startTime := time.Now() - leftTime := gcSafePointCacheInterval - for { - time.Sleep(leftTime) - leftTime = time.Since(startTime) - gcSafePointCacheInterval - if leftTime <= 0 { - break - } - } - } + + // Sleep to wait for all other tidb instances update their safepoint cache. + time.Sleep(gcSafePointCacheInterval) req := &tikvrpc.Request{ Type: tikvrpc.CmdGC,