mirror of https://github.com/tikv/client-go.git
parent
1ee6c84e7d
commit
3f36b93a7d
10
tikv/kv.go
10
tikv/kv.go
|
|
@ -585,12 +585,10 @@ func (s *KVStore) updateSafeTS(ctx context.Context) {
|
|||
wg := &sync.WaitGroup{}
|
||||
wg.Add(len(stores))
|
||||
// Try to get the minimum resolved timestamp of the store from PD.
|
||||
var (
|
||||
storeIDs []string
|
||||
err error
|
||||
)
|
||||
for _, store := range stores {
|
||||
storeIDs = append(storeIDs, strconv.FormatUint(store.StoreID(), 10))
|
||||
var err error
|
||||
storeIDs := make([]string, len(stores))
|
||||
for i, store := range stores {
|
||||
storeIDs[i] = strconv.FormatUint(store.StoreID(), 10)
|
||||
}
|
||||
storeMinResolvedTSs := make(map[uint64]uint64)
|
||||
if s.pdHttpClient != nil {
|
||||
|
|
|
|||
11
util/pd.go
11
util/pd.go
|
|
@ -96,13 +96,16 @@ func (p *PDHTTPClient) GetMinResolvedTSByStoresIDs(ctx context.Context, storeIDs
|
|||
logutil.BgLogger().Debug("failed to marshal store ids", zap.String("addr", addr), zap.Error(err))
|
||||
return nil, errors.Trace(err)
|
||||
}
|
||||
v, e := pdRequest(ctx, addr, minResolvedTSPrefix, p.cli, http.MethodGet, bytes.NewBuffer(data))
|
||||
if e != nil {
|
||||
logutil.BgLogger().Debug("failed to get min resolved ts", zap.String("addr", addr), zap.Error(e))
|
||||
err = e
|
||||
v, err := pdRequest(ctx, addr, minResolvedTSPrefix, p.cli, http.MethodGet, bytes.NewBuffer(data))
|
||||
if err != nil {
|
||||
logutil.BgLogger().Debug("failed to get min resolved ts", zap.String("addr", addr), zap.Error(err))
|
||||
continue
|
||||
}
|
||||
logutil.BgLogger().Debug("min resolved ts", zap.String("resp", string(v)))
|
||||
// - When no store is given, cluster-level's min_resolved_ts will be returned,
|
||||
// and min_resolved_ts for each store will be empty.
|
||||
// - When given a list of stores, min_resolved_ts will be provided for each store
|
||||
// and the scope-specific min_resolved_ts will be returned.
|
||||
d := struct {
|
||||
IsRealTime bool `json:"is_real_time,omitempty"`
|
||||
StoresMinResolvedTS map[uint64]uint64 `json:"stores_min_resolved_ts"`
|
||||
|
|
|
|||
Loading…
Reference in New Issue