-
Notifications
You must be signed in to change notification settings - Fork 721
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
Init TSO service and start service loop #6008
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Hi @binshi-bing. Thanks for your PR. I'm waiting for a tikv member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Codecov ReportBase: 74.79% // Head: 74.12% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #6008 +/- ##
==========================================
- Coverage 74.79% 74.12% -0.68%
==========================================
Files 368 373 +5
Lines 36661 37335 +674
==========================================
+ Hits 27422 27676 +254
- Misses 6833 7213 +380
- Partials 2406 2446 +40
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
/ok-to-test |
6804a62
to
6e12e28
Compare
6362b67
to
9d17974
Compare
Signed-off-by: lhy1024 <[email protected]>
6fbe238
to
f355f92
Compare
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, except for leave comment
1204a9a
to
1404156
Compare
Signed-off-by: Bin Shi <[email protected]> Add Participant which is non-embedded-etcd version of Member. Rename Member to the EmbeddedEtcdMember. Add Member interface which defines the behavior of a member particpating in an election regardless of concrete mechanism behind. Decouple embedded etcd from TSO AllocatorManager, GlobalTSOAllocator and LocalTSOAllocator. Signed-off-by: Bin Shi <[email protected]> Refactor the GRPC and HTTP Server start logic. It refers to DGraph https://github.com/binshi-bing/dgraph/blob/cbec2309413a9b17d407b3417300f719381b36d7/dgraph/cmd/zero/run.go#L318-L319 and cmux example https://github.com/soheilhy/cmux/blob/5ec6847320e53b5fee0ab9a4757b56625a946c85/example/example_test.go#L108. Signed-off-by: Bin Shi <[email protected]> Add TSO primary/leader election loop and adjust config with default values. Changes: 1. Add TSO primary/leader election loop 2. Add tso.Config.Adjust() to adjust config with default values if they're not in configuration file or passed from commandline. Signed-off-by: Bin Shi <[email protected]> Handle feedbacks Signed-off-by: Bin Shi <[email protected]> Update defaultListenAddr = 127.0.0.1:3379 and defaultHTTPGracefulShutdownTimeout = 5 * time.Second Signed-off-by: Bin Shi <[email protected]> rebase master Signed-off-by: Bin Shi <[email protected]> Handle feedbacks Signed-off-by: Bin Shi <[email protected]> Update the key for keyspace group primary election (e.g., /pd/microservice/tso/keyspace-group-00000/primary) The entire key is in the format of "/pd/microservice/tso/keyspace-group-XXXXX/primary" in which XXXXX is 5 digits integer with leading zeros. For example, the key for keyspace group 0 primary election is "/pd/microservice/tso/keyspace-group-00000/primary" Signed-off-by: Bin Shi <[email protected]> Update the format of the key for keyspace group primary electio to "/pd/<cluster-id>/microservice/tso/keyspace-group-XXXXX/primary". For now we use 0 as the default cluster id. Signed-off-by: Bin Shi <[email protected]> Refactor log when grpc/http server stops serving Signed-off-by: Bin Shi <[email protected]> Handle feedback -- move Member interface to pkg/tso to keep the just-right visibility Signed-off-by: Bin Shi <[email protected]> Add unique name/id for Compaign Election and fix a bug in Primary Election loop. Passed HA/Failure test on local box. Signed-off-by: Bin Shi <[email protected]> Set cluster id to default value 0 for now to satisfy the cluster id verification between the client and the server side. Signed-off-by: Bin Shi <[email protected]> Add TSO Server Start/Stop Unittest. Signed-off-by: Bin Shi <[email protected]>
Signed-off-by: Bin Shi <[email protected]>
Signed-off-by: Bin Shi <[email protected]>
Signed-off-by: Bin Shi <[email protected]>
1404156
to
e6cd0a8
Compare
/merge |
@lhy1024: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
This pull request has been accepted and is ready to merge. Commit hash: e6cd0a8
|
…e's commit by mistake. Signed-off-by: Bin Shi <[email protected]>
/merge |
@lhy1024: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
This pull request has been accepted and is ready to merge. Commit hash: d140827
|
tsoRootPath = "/tso" | ||
tsoClusterIDPath = "/tso/cluster_id" | ||
// tsoKeyspaceGroupPrimaryElectionPrefix defines the key prefix for keyspace group primary election. | ||
// The entire key is in the format of "/pd/<cluster-id>/microservice/tso/keyspace-group-XXXXX/primary" in which |
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.
maybe /pd/<cluster-id>/microservice/tso/<group-id>/primary
looks better in here.
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.
Yes, we can certainly move "keyspace-group-" from the path to make it more compact.
@binshi-bing: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
What problem does this PR solve?
Issue Number: Ref #5836
What is changed and how does it work?
Check List
Tests
Start:
[2023/02/22 22:46:02.566 -08:00] [INFO] [metricutil.go:83] ["disable Prometheus push client"]
[2023/02/22 22:46:02.566 -08:00] [INFO] [systimemon.go:28] ["start system time monitor"]
[2023/02/22 22:46:02.566 -08:00] [INFO] [etcdutil.go:232] ["create etcd v3 client"] [endpoints="[http://127.0.0.1:2379/]"]
[2023/02/22 22:46:02.574 -08:00] [INFO] [server.go:533] ["init cluster id"] [cluster-id=7203238955249386415]
[2023/02/22 22:46:02.590 -08:00] [INFO] [server.go:574] ["triggering the start callback functions"]
[2023/02/22 22:46:02.590 -08:00] [INFO] [server.go:198] ["start to campaign the primary/leader"] [campaign-tso-primary-name=TSO-Bins-MacBook-Pro.local]
[2023/02/22 22:46:02.596 -08:00] [INFO] [lease.go:65] ["lease granted"] [lease-id=2463898342467820709] [lease-timeout=3] [purpose="keyspace group primary election"]
[2023/02/22 22:46:02.601 -08:00] [INFO] [leadership.go:122] ["check campaign resp"] [resp="{"header":{"cluster_id":15674009460217235928,"member_id":3474484975246189105,"revision":1383,"raft_term":2},"succeeded":true,"responses":[{"Response":{"ResponsePut":{"header":{"revision":1383}}}}]}"]
[2023/02/22 22:46:02.601 -08:00] [INFO] [leadership.go:131] ["write leaderData to leaderPath ok"] [leaderPath=/pd/0/microservice/tso/keyspace-group-00000/primary] [purpose="keyspace group primary election"]
[2023/02/22 22:46:02.601 -08:00] [INFO] [server.go:224] ["campaign tso primary/leader ok"] [campaign-tso-primary-name=TSO-Bins-MacBook-Pro.local]
[2023/02/22 22:46:02.601 -08:00] [INFO] [server.go:231] ["initializing the global tso allocator"]
[2023/02/22 22:46:02.601 -08:00] [INFO] [lease.go:135] ["start lease keep alive worker"] [interval=1s] [purpose="keyspace group primary election"]
[2023/02/22 22:46:02.606 -08:00] [INFO] [tso.go:227] ["sync and save timestamp"] [last=0001/01/01 00:00:00.000 +00:00] [save=2023/02/22 22:46:05.601 -08:00] [next=2023/02/22 22:46:02.601 -08:00]
[2023/02/22 22:46:02.606 -08:00] [INFO] [server.go:240] ["triggering the primary callback functions"]
[2023/02/22 22:46:02.606 -08:00] [INFO] [server.go:248] ["tso cluster primary server is ready to serve"] [tso-primary-name=TSO-Bins-MacBook-Pro.local]
Exit:
[2023/02/22 23:00:17.642 -08:00] [INFO] [server.go:648] ["got signal to exit"] [signal=interrupt]
[2023/02/22 23:00:17.642 -08:00] [INFO] [lease.go:159] ["stop lease keep alive worker"] [purpose="keyspace group primary election"]
[2023/02/22 23:00:17.642 -08:00] [INFO] [server.go:262] ["server is closed"]
[2023/02/22 23:00:17.642 -08:00] [INFO] [server.go:275] ["closing tso server ..."]
[2023/02/22 23:00:17.642 -08:00] [INFO] [tso.go:416] ["reset the timestamp in memory"]
[2023/02/22 23:00:17.642 -08:00] [INFO] [server.go:522] ["mux stop serving"] [error="accept tcp 127.0.0.1:3379: use of closed network connection"]
[2023/02/22 23:00:17.642 -08:00] [INFO] [server.go:459] ["grpc server stopped serving"]
[2023/02/22 23:00:17.642 -08:00] [INFO] [server.go:493] ["http server stopped serving"]
[2023/02/22 23:00:17.642 -08:00] [INFO] [server.go:465] ["try to gracefully stop the server now"]
[2023/02/22 23:00:17.642 -08:00] [INFO] [server.go:477] ["grpc server stopped"]
[2023/02/22 23:00:17.642 -08:00] [INFO] [server.go:500] ["all http(s) requests finished"]
[2023/02/22 23:00:17.642 -08:00] [INFO] [server.go:503] ["http server stopped"]
[2023/02/22 23:00:17.647 -08:00] [INFO] [server.go:166] ["tso server is closed, exit allocator loop"]
[2023/02/22 23:00:17.656 -08:00] [WARN] [retry_interceptor.go:62] ["retrying of unary invoker failed"] [target=endpoint://client-62ef1518-1368-4d7a-b433-a76b35778818/127.0.0.1:2379] [attempt=0] [error="rpc error: code = NotFound desc = etcdserver: requested lease not found"]
[2023/02/22 23:00:17.656 -08:00] [INFO] [server.go:175] ["server is closed, exit tso primary election loop"]
[2023/02/22 23:00:17.657 -08:00] [INFO] [server.go:292] ["tso server is closed"]
Code changes
Release note