Skip to content

Commit

Permalink
make ci happy
Browse files Browse the repository at this point in the history
Signed-off-by: husharp <jinhao.hu@pingcap.com>
  • Loading branch information
HuSharp committed Aug 14, 2023
1 parent d8451eb commit b771e63
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
8 changes: 5 additions & 3 deletions tikv/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ func (s *KVStore) updateSafeTS(ctx context.Context) {
wg.Add(len(stores))
// Try to get the minimum resolved timestamp of the store from PD.
var err error
storeMinResolvedTSs := make(map[uint64]uint64)
var storeMinResolvedTSs map[uint64]uint64
if s.pdHttpClient != nil {
storeIDs := make([]string, len(stores))
for i, store := range stores {
Expand All @@ -608,10 +608,10 @@ func (s *KVStore) updateSafeTS(ctx context.Context) {
go func(ctx context.Context, wg *sync.WaitGroup, storeID uint64, storeAddr string) {
defer wg.Done()

safeTS := storeMinResolvedTSs[storeID]
var safeTS uint64
storeIDStr := strconv.FormatUint(storeID, 10)
// If getting the minimum resolved timestamp from PD failed or returned 0, try to get it from TiKV.
if safeTS == 0 || err != nil {
if storeMinResolvedTSs == nil || storeMinResolvedTSs[storeID] == 0 || err != nil {
resp, err := tikvClient.SendRequest(
ctx, storeAddr, tikvrpc.NewRequest(
tikvrpc.CmdStoreSafeTS, &kvrpcpb.StoreSafeTSRequest{
Expand All @@ -630,6 +630,8 @@ func (s *KVStore) updateSafeTS(ctx context.Context) {
return
}
safeTS = resp.Resp.(*kvrpcpb.StoreSafeTSResponse).GetSafeTs()
} else {
safeTS = storeMinResolvedTSs[storeID]
}

_, preSafeTS := s.getSafeTS(storeID)
Expand Down
24 changes: 18 additions & 6 deletions util/pd.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func (p *PDHTTPClient) GetMinResolvedTSByStoresIDs(ctx context.Context, storeIDs
v, e := pdRequest(ctx, addr, query, p.cli, http.MethodGet, nil)
if e != nil {
logutil.BgLogger().Debug("failed to get min resolved ts", zap.String("addr", addr), zap.Error(e))
err = e
continue
}
logutil.BgLogger().Debug("min resolved ts", zap.String("resp", string(v)))
Expand All @@ -117,14 +118,25 @@ func (p *PDHTTPClient) GetMinResolvedTSByStoresIDs(ctx context.Context, storeIDs
}
if val, e := EvalFailpoint("InjectMinResolvedTS"); e == nil {
// Need to make sure successfully get from real pd.
for storeID, v := range d.StoresMinResolvedTS {
if v != 0 {
// Should be val.(uint64) but failpoint doesn't support that.
if tmp, ok := val.(int); ok {
d.StoresMinResolvedTS[storeID] = uint64(tmp)
logutil.BgLogger().Info("inject min resolved ts", zap.Uint64("storeID", storeID), zap.Uint64("ts", uint64(tmp)))
if d.StoresMinResolvedTS != nil {
for storeID, v := range d.StoresMinResolvedTS {
if v != 0 {
// Should be val.(uint64) but failpoint doesn't support that.
if tmp, ok := val.(int); ok {
d.StoresMinResolvedTS[storeID] = uint64(tmp)
logutil.BgLogger().Info("inject min resolved ts", zap.Uint64("storeID", storeID), zap.Uint64("ts", uint64(tmp)))
}
}
}
} else {
// Should be val.(uint64) but failpoint doesn't support that.
if tmp, ok := val.(int); ok {
// ci's store id is 1, we can change it if we have more stores.
// but for pool ci it's no need to do that :(
d.StoresMinResolvedTS = make(map[uint64]uint64)
d.StoresMinResolvedTS[1] = uint64(tmp)
logutil.BgLogger().Info("inject min resolved ts", zap.Uint64("ts", uint64(tmp)))
}
}

}
Expand Down

0 comments on commit b771e63

Please sign in to comment.