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

store/tikv,mysql: improve error message of GC life time #7658

Merged
merged 4 commits into from
Sep 11, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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 mysql/errname.go
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ var MySQLErrName = map[uint16]string{
ErrTiKVServerBusy: "TiKV server is busy",
ErrResolveLockTimeout: "Resolve lock timeout",
ErrRegionUnavailable: "Region is unavailable",
ErrGCTooEarly: "GC life time is shorter than transaction duration",
ErrGCTooEarly: "GC life time is shorter than transaction duration, transaction starts at %v, GC safe point is %v",

ErrTxnTooLarge: "Transaction is too large",
}
4 changes: 3 additions & 1 deletion store/tikv/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ func (s *tikvStore) CheckVisibility(startTime uint64) error {
}

if startTime < cachedSafePoint {
return ErrGCTooEarly
t1 := oracle.GetTimeFromTS(startTime)
t2 := oracle.GetTimeFromTS(cachedSafePoint)
return ErrGCTooEarly.GenByArgs(t1, t2)
}

return nil
Expand Down
6 changes: 6 additions & 0 deletions store/tikv/oracle/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@ func GetPhysical(t time.Time) int64 {
func EncodeTSO(ts int64) uint64 {
return uint64(ts) << physicalShiftBits
}

// GetTimeFromTS extracts time.Time from a timestamp.
func GetTimeFromTS(ts uint64) time.Time {
ms := ExtractPhysical(ts)
return time.Unix(ms/1000, (ms%1000)*1e6)
}