fix error

Signed-off-by: husharp <jinhao.hu@pingcap.com>
This commit is contained in:
husharp 2023-08-09 10:29:01 +08:00
parent 1ee6c84e7d
commit 3f36b93a7d
2 changed files with 11 additions and 10 deletions

View File

@ -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 {

View File

@ -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"`