-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
domain: report min start timestamp of TiDB server #12133
Conversation
Signed-off-by: Shuaipeng Yu <jackysp@gmail.com>
Signed-off-by: Shuaipeng Yu <jackysp@gmail.com>
Signed-off-by: Shuaipeng Yu <jackysp@gmail.com>
Signed-off-by: Shuaipeng Yu <jackysp@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #12133 +/- ##
=========================================
Coverage 81.428% 81.428%
=========================================
Files 454 454
Lines 100000 100000
=========================================
Hits 81428 81428
Misses 12805 12805
Partials 5767 5767 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
} | ||
return util.PutKVToEtcd(ctx, is.etcdCli, keyOpDefaultRetryCnt, is.minStartTSPath, | ||
strconv.FormatUint(is.minStartTS, 10), | ||
clientv3.WithLease(is.session.Lease())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does all TiDB servers updates the same key in etcd? If so, how do TiDB servers know whether there's another TiDB server who has a smaller minStartTs
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I got it. LGTM.
} | ||
pl := is.manager.ShowProcessList() | ||
var minStartTS uint64 = math.MaxUint64 | ||
for _, info := range pl { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if len(pl) == 0
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Report max uint64 to PD.
If a tidb-server is killed -9, how long will the minStartTS be kept in PD? |
1 min. It used the same TTL as server info, Line 221 in fbc6a84
|
Signed-off-by: Shuaipeng Yu <jackysp@gmail.com>
PTAL @coocood |
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -49,6 +54,9 @@ type InfoSyncer struct { | |||
etcdCli *clientv3.Client | |||
info *ServerInfo | |||
serverInfoPath string | |||
minStartTS uint64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that we don't need this field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be used by the next PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
@jackysp merge failed. |
/merge |
/run-all-tests |
What problem does this PR solve?
The server current min start timestamp could be reported to PD, it may be used to calculate a more reasonable safe point for GC.
What is changed and how it works?
Report min start timestamp to PD.
Check List
Tests
ETCDCTL_API=3 ./etcdctl --endpoints="http://172.16.5.34:2380" get / --prefix
gets the key/tidb/server/minstartts/xxx
Code changes