Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change get min ts function name #1251

Merged
merged 6 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/gcworker/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/rawkv/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/txnkv/1pc_txn/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/txnkv/async_commit/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/txnkv/delete_range/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/txnkv/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/txnkv/pessimistic_txn/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/txnkv/unsafedestoryrange/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion oracle/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
ystaticy marked this conversation as resolved.
Show resolved Hide resolved
}

// Future is a future which promises to return a timestamp.
Expand Down
2 changes: 1 addition & 1 deletion oracle/oracles/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions oracle/oracles/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
8 changes: 4 additions & 4 deletions oracle/oracles/pd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions tikv/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
Loading