Skip to content

Commit

Permalink
*: add warn log for stale read (pingcap#30340)
Browse files Browse the repository at this point in the history
Signed-off-by: yisaer <disxiaofei@163.com>
  • Loading branch information
Yisaer committed Dec 9, 2021
1 parent dd78177 commit ca901be
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions expression/builtin_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -7188,11 +7188,21 @@ func CalAppropriateTime(minTime, maxTime, minSafeTime time.Time) time.Time {
// 2. If t2 < t, we will use t2 as the result,
// and with it, a read request won't fail because it's bigger than the latest SafeTS.
func calAppropriateTime(minTime, maxTime, minSafeTime time.Time) time.Time {
if minSafeTime.Before(minTime) {
return minTime
} else if minSafeTime.After(maxTime) {
return maxTime
}
if minSafeTime.Before(minTime) || minSafeTime.After(maxTime) {
logutil.BgLogger().Warn("calAppropriateTime",
zap.Time("minTime", minTime),
zap.Time("maxTime", maxTime),
zap.Time("minSafeTime", minSafeTime))
if minSafeTime.Before(minTime) {
return minTime
} else if minSafeTime.After(maxTime) {
return maxTime
}
}
logutil.BgLogger().Debug("calAppropriateTime",
zap.Time("minTime", minTime),
zap.Time("maxTime", maxTime),
zap.Time("minSafeTime", minSafeTime))
return minSafeTime
}

Expand Down

0 comments on commit ca901be

Please sign in to comment.