diff --git a/examples/gcworker/go.mod b/examples/gcworker/go.mod index 1da7b81d4..2159df803 100644 --- a/examples/gcworker/go.mod +++ b/examples/gcworker/go.mod @@ -30,7 +30,7 @@ require ( github.com/prometheus/procfs v0.12.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect - github.com/tikv/pd/client v0.0.0-20240229062430-b207e514ece1 // indirect + github.com/tikv/pd/client v0.0.0-20240320081713-c00c42e77b31 // indirect github.com/twmb/murmur3 v1.1.3 // indirect go.etcd.io/etcd/api/v3 v3.5.10 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect diff --git a/examples/rawkv/go.mod b/examples/rawkv/go.mod index a0ea6f67b..45a1c4d08 100644 --- a/examples/rawkv/go.mod +++ b/examples/rawkv/go.mod @@ -30,7 +30,7 @@ require ( github.com/prometheus/procfs v0.12.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect - github.com/tikv/pd/client v0.0.0-20240229062430-b207e514ece1 // indirect + github.com/tikv/pd/client v0.0.0-20240320081713-c00c42e77b31 // indirect github.com/twmb/murmur3 v1.1.3 // indirect go.etcd.io/etcd/api/v3 v3.5.10 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect diff --git a/examples/txnkv/1pc_txn/go.mod b/examples/txnkv/1pc_txn/go.mod index 70825849b..224ff0bb6 100644 --- a/examples/txnkv/1pc_txn/go.mod +++ b/examples/txnkv/1pc_txn/go.mod @@ -30,7 +30,7 @@ require ( github.com/prometheus/procfs v0.12.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect - github.com/tikv/pd/client v0.0.0-20240229062430-b207e514ece1 // indirect + github.com/tikv/pd/client v0.0.0-20240320081713-c00c42e77b31 // indirect github.com/twmb/murmur3 v1.1.3 // indirect go.etcd.io/etcd/api/v3 v3.5.10 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect diff --git a/examples/txnkv/async_commit/go.mod b/examples/txnkv/async_commit/go.mod index 046d68df6..1253bbde7 100644 --- a/examples/txnkv/async_commit/go.mod +++ b/examples/txnkv/async_commit/go.mod @@ -30,7 +30,7 @@ require ( github.com/prometheus/procfs v0.12.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect - github.com/tikv/pd/client v0.0.0-20240229062430-b207e514ece1 // indirect + github.com/tikv/pd/client v0.0.0-20240320081713-c00c42e77b31 // indirect github.com/twmb/murmur3 v1.1.3 // indirect go.etcd.io/etcd/api/v3 v3.5.10 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect diff --git a/examples/txnkv/delete_range/go.mod b/examples/txnkv/delete_range/go.mod index 704dd51da..504dd55ad 100644 --- a/examples/txnkv/delete_range/go.mod +++ b/examples/txnkv/delete_range/go.mod @@ -30,7 +30,7 @@ require ( github.com/prometheus/procfs v0.12.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect - github.com/tikv/pd/client v0.0.0-20240229062430-b207e514ece1 // indirect + github.com/tikv/pd/client v0.0.0-20240320081713-c00c42e77b31 // indirect github.com/twmb/murmur3 v1.1.3 // indirect go.etcd.io/etcd/api/v3 v3.5.10 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect diff --git a/examples/txnkv/go.mod b/examples/txnkv/go.mod index bb1508e21..59cb804d7 100644 --- a/examples/txnkv/go.mod +++ b/examples/txnkv/go.mod @@ -30,7 +30,7 @@ require ( github.com/prometheus/procfs v0.12.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect - github.com/tikv/pd/client v0.0.0-20240229062430-b207e514ece1 // indirect + github.com/tikv/pd/client v0.0.0-20240320081713-c00c42e77b31 // indirect github.com/twmb/murmur3 v1.1.3 // indirect go.etcd.io/etcd/api/v3 v3.5.10 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect diff --git a/examples/txnkv/pessimistic_txn/go.mod b/examples/txnkv/pessimistic_txn/go.mod index 491287ca2..4059cefa2 100644 --- a/examples/txnkv/pessimistic_txn/go.mod +++ b/examples/txnkv/pessimistic_txn/go.mod @@ -30,7 +30,7 @@ require ( github.com/prometheus/procfs v0.12.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect - github.com/tikv/pd/client v0.0.0-20240229062430-b207e514ece1 // indirect + github.com/tikv/pd/client v0.0.0-20240320081713-c00c42e77b31 // indirect github.com/twmb/murmur3 v1.1.3 // indirect go.etcd.io/etcd/api/v3 v3.5.10 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect diff --git a/examples/txnkv/unsafedestoryrange/go.mod b/examples/txnkv/unsafedestoryrange/go.mod index 39450ee27..202531c6d 100644 --- a/examples/txnkv/unsafedestoryrange/go.mod +++ b/examples/txnkv/unsafedestoryrange/go.mod @@ -30,7 +30,7 @@ require ( github.com/prometheus/procfs v0.12.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect - github.com/tikv/pd/client v0.0.0-20240229062430-b207e514ece1 // indirect + github.com/tikv/pd/client v0.0.0-20240320081713-c00c42e77b31 // indirect github.com/twmb/murmur3 v1.1.3 // indirect go.etcd.io/etcd/api/v3 v3.5.10 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect diff --git a/oracle/oracle.go b/oracle/oracle.go index a72cff7c4..5579d3568 100644 --- a/oracle/oracle.go +++ b/oracle/oracle.go @@ -59,7 +59,8 @@ type Oracle interface { GetExternalTimestamp(ctx context.Context) (uint64, error) SetExternalTimestamp(ctx context.Context, ts uint64) error - GetMinTimestamp(ctx context.Context) (uint64, error) + // GetAllTSOKeyspaceGroupMinTS gets a minimum timestamp from all TSO keyspace groups. + GetAllTSOKeyspaceGroupMinTS(ctx context.Context) (uint64, error) } // Future is a future which promises to return a timestamp. diff --git a/oracle/oracles/local.go b/oracle/oracles/local.go index 018047de0..f8016f468 100644 --- a/oracle/oracles/local.go +++ b/oracle/oracles/local.go @@ -86,7 +86,7 @@ func (l *localOracle) GetTimestamp(ctx context.Context, _ *oracle.Option) (uint6 return ts, nil } -func (l *localOracle) GetMinTimestamp(ctx context.Context) (uint64, error) { +func (l *localOracle) GetAllTSOKeyspaceGroupMinTS(ctx context.Context) (uint64, error) { l.Lock() defer l.Unlock() now := time.Now() diff --git a/oracle/oracles/mock.go b/oracle/oracles/mock.go index 6e23bd0f4..633d97537 100644 --- a/oracle/oracles/mock.go +++ b/oracle/oracles/mock.go @@ -93,8 +93,8 @@ func (o *MockOracle) GetTimestamp(ctx context.Context, _ *oracle.Option) (uint64 return ts, nil } -// GetMinTimestamp implements oracle.Oracle interface. -func (o *MockOracle) GetMinTimestamp(ctx context.Context) (uint64, error) { +// GetAllTSOKeyspaceGroupMinTS implements oracle.Oracle interface. +func (o *MockOracle) GetAllTSOKeyspaceGroupMinTS(ctx context.Context) (uint64, error) { o.RLock() defer o.RUnlock() diff --git a/oracle/oracles/pd.go b/oracle/oracles/pd.go index 01301fd3c..83dd41f3c 100644 --- a/oracle/oracles/pd.go +++ b/oracle/oracles/pd.go @@ -115,9 +115,9 @@ func (o *pdOracle) GetTimestamp(ctx context.Context, opt *oracle.Option) (uint64 return ts, nil } -// GetMinTimestamp gets a minimum timestamp for all keyspace groups. -func (o *pdOracle) GetMinTimestamp(ctx context.Context) (uint64, error) { - return o.getMinTimestamp(ctx) +// GetAllTSOKeyspaceGroupMinTS gets a minimum timestamp from all TSO keyspace groups. +func (o *pdOracle) GetAllTSOKeyspaceGroupMinTS(ctx context.Context) (uint64, error) { + return o.getMinTimestampInAllTSOGroup(ctx) } type tsFuture struct { @@ -171,7 +171,7 @@ func (o *pdOracle) getTimestamp(ctx context.Context, txnScope string) (uint64, e return oracle.ComposeTS(physical, logical), nil } -func (o *pdOracle) getMinTimestamp(ctx context.Context) (uint64, error) { +func (o *pdOracle) getMinTimestampInAllTSOGroup(ctx context.Context) (uint64, error) { now := time.Now() physical, logical, err := o.c.GetMinTS(ctx) diff --git a/tikv/kv.go b/tikv/kv.go index 34b5fa24d..7d2dec3cf 100644 --- a/tikv/kv.go +++ b/tikv/kv.go @@ -425,10 +425,10 @@ func (s *KVStore) CurrentTimestamp(txnScope string) (uint64, error) { return startTS, nil } -// CurrentMinTimestamp returns current timestamp across all keyspace groups. -func (s *KVStore) CurrentMinTimestamp() (uint64, error) { +// CurrentAllTSOKeyspaceMinTsGroup returns a minimum timestamp from all TSO keyspace groups. +func (s *KVStore) CurrentAllTSOKeyspaceMinTsGroup() (uint64, error) { bo := retry.NewBackofferWithVars(context.Background(), transaction.TsoMaxBackoff, nil) - startTS, err := s.getMinTimestampWithRetry(bo) + startTS, err := s.getAllTSOKeyspaceGroupMinTSWithRetry(bo) if err != nil { return 0, err } @@ -469,15 +469,15 @@ func (s *KVStore) getTimestampWithRetry(bo *Backoffer, txnScope string) (uint64, } } -func (s *KVStore) getMinTimestampWithRetry(bo *Backoffer) (uint64, error) { +func (s *KVStore) getAllTSOKeyspaceGroupMinTSWithRetry(bo *Backoffer) (uint64, error) { if span := opentracing.SpanFromContext(bo.GetCtx()); span != nil && span.Tracer() != nil { - span1 := span.Tracer().StartSpan("TiKVStore.getMinTimestampWithRetry", opentracing.ChildOf(span.Context())) + span1 := span.Tracer().StartSpan("TiKVStore.getAllTSOKeyspaceGroupMinTSWithRetry", opentracing.ChildOf(span.Context())) defer span1.Finish() bo.SetCtx(opentracing.ContextWithSpan(bo.GetCtx(), span1)) } for { - minTS, err := s.oracle.GetMinTimestamp(bo.GetCtx()) + minTS, err := s.oracle.GetAllTSOKeyspaceGroupMinTS(bo.GetCtx()) if err == nil { return minTS, nil }