Skip to content

Commit

Permalink
store/tikv/gc_worker: Add RunDistributedGCJob function (pingcap#10369)
Browse files Browse the repository at this point in the history
Signed-off-by: MyonKeminta <[email protected]>
  • Loading branch information
MyonKeminta authored May 8, 2019
1 parent 1690912 commit d5fcfb0
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion store/tikv/gcworker/gc_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ func (w *GCWorker) saveValueToSysTable(key, value string) error {
return errors.Trace(err)
}

// RunGCJob sends GC command to KV. it is exported for kv api, do not use it with GCWorker at the same time.
// RunGCJob sends GC command to KV. It is exported for kv api, do not use it with GCWorker at the same time.
func RunGCJob(ctx context.Context, s tikv.Storage, safePoint uint64, identifier string, concurrency int) error {
gcWorker := &GCWorker{
store: s,
Expand All @@ -1204,6 +1204,27 @@ func RunGCJob(ctx context.Context, s tikv.Storage, safePoint uint64, identifier
return nil
}

// RunDistributedGCJob notifies TiKVs to do GC. It is exported for kv api, do not use it with GCWorker at the same time.
// This function may not finish immediately because it may take some time to do resolveLocks.
func RunDistributedGCJob(ctx context.Context, s tikv.Storage, pd pd.Client, safePoint uint64, identifier string) error {
gcWorker := &GCWorker{
store: s,
uuid: identifier,
pdClient: pd,
}

err := gcWorker.resolveLocks(ctx, safePoint)
if err != nil {
return errors.Trace(err)
}

err = gcWorker.uploadSafePointToPD(ctx, safePoint)
if err != nil {
return errors.Trace(err)
}
return nil
}

// MockGCWorker is for test.
type MockGCWorker struct {
worker *GCWorker
Expand Down

0 comments on commit d5fcfb0

Please sign in to comment.