Skip to content

Commit

Permalink
GC : fix issue of delete range could not be executed again if the cle…
Browse files Browse the repository at this point in the history
…aning rules failed (#53368) (#56991)

ref #53369
  • Loading branch information
ystaticy authored Oct 31, 2024
1 parent aad5075 commit c5dc4ba
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
20 changes: 10 additions & 10 deletions store/gcworker/gc_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -892,16 +892,6 @@ func (w *GCWorker) deleteRanges(ctx context.Context, safePoint uint64, concurren
continue
}

err = util.CompleteDeleteRange(se, r, !v2)
if err != nil {
logutil.Logger(ctx).Error("[gc worker] failed to mark delete range task done",
zap.String("uuid", w.uuid),
zap.Stringer("startKey", startKey),
zap.Stringer("endKey", endKey),
zap.Error(err))
metrics.GCUnsafeDestroyRangeFailuresCounterVec.WithLabelValues("save").Inc()
}

if err := w.doGCPlacementRules(se, safePoint, r, gcPlacementRuleCache); err != nil {
logutil.Logger(ctx).Error("[gc worker] gc placement rules failed on range",
zap.String("uuid", w.uuid),
Expand All @@ -918,6 +908,16 @@ func (w *GCWorker) deleteRanges(ctx context.Context, safePoint uint64, concurren
zap.Error(err))
continue
}

err = util.CompleteDeleteRange(se, r, !v2)
if err != nil {
logutil.Logger(ctx).Error("[gc worker] failed to mark delete range task done",
zap.String("uuid", w.uuid),
zap.Stringer("startKey", startKey),
zap.Stringer("endKey", endKey),
zap.Error(err))
metrics.GCUnsafeDestroyRangeFailuresCounterVec.WithLabelValues("save").Inc()
}
}
logutil.Logger(ctx).Info("[gc worker] finish delete ranges",
zap.String("uuid", w.uuid),
Expand Down
15 changes: 15 additions & 0 deletions store/gcworker/gc_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,11 @@ func TestDeleteRangesFailure(t *testing.T) {
require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/store/gcworker/mockHistoryJobForGC"))
}()

require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/store/gcworker/mockHistoryJob", "return(\"schema/d1/t1\")"))
defer func() {
require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/store/gcworker/mockHistoryJob"))
}()

// Put some delete range tasks.
se := createSession(s.gcWorker.store)
defer se.Close()
Expand Down Expand Up @@ -847,6 +852,16 @@ Loop:
func TestUnsafeDestroyRangeForRaftkv2(t *testing.T) {
require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/store/gcworker/isRaftKv2", "return(true)"))

require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/store/gcworker/mockHistoryJobForGC", "return(1)"))
defer func() {
require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/store/gcworker/mockHistoryJobForGC"))
}()

require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/store/gcworker/mockHistoryJob", "return(\"schema/d1/t1\")"))
defer func() {
require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/store/gcworker/mockHistoryJob"))
}()

s := createGCWorkerSuite(t)
// Put some delete range tasks.
se := createSession(s.gcWorker.store)
Expand Down

0 comments on commit c5dc4ba

Please sign in to comment.