store/tikv/gc_worker: Add RunDistributedGCJob function (#10369)
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
This commit is contained in:
@ -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,
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user