pdms: support primary/transfer api for scheduling and tso#8157
pdms: support primary/transfer api for scheduling and tso#8157ti-chi-bot[bot] merged 37 commits intotikv:masterfrom
Conversation
|
[REVIEW NOTIFICATION] This pull request has not been approved. 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. DetailsReviewer can indicate their review by submitting an approval review. |
Signed-off-by: husharp <jinhao.hu@pingcap.com>
510f18d to
7fa19d3
Compare
480b075 to
2a647ac
Compare
Signed-off-by: husharp <jinhao.hu@pingcap.com>
2a647ac to
1f13fa2
Compare
Signed-off-by: husharp <jinhao.hu@pingcap.com>
5490d10 to
02a8c4a
Compare
Signed-off-by: husharp <jinhao.hu@pingcap.com>
02a8c4a to
8d36be5
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8157 +/- ##
==========================================
+ Coverage 77.40% 77.49% +0.08%
==========================================
Files 472 473 +1
Lines 61821 61934 +113
==========================================
+ Hits 47854 47993 +139
+ Misses 10400 10373 -27
- Partials 3567 3568 +1
Flags with carried forward coverage won't be shown. Click here to find out more. |
Signed-off-by: husharp <jinhao.hu@pingcap.com>
Signed-off-by: husharp <jinhao.hu@pingcap.com>
1fe976d to
dd72b9c
Compare
Signed-off-by: husharp <jinhao.hu@pingcap.com>
Signed-off-by: husharp <jinhao.hu@pingcap.com>
| } | ||
|
|
||
| flagSet := pflag.NewFlagSet("test", pflag.ContinueOnError) | ||
| flagSet.StringP("name", "", "", "human-readable name for this scheduling member") |
There was a problem hiding this comment.
default name set by this code, which is like TSO-localhost
pd/pkg/mcs/tso/server/config.go
Lines 185 to 195 in a39300e
And your commented snippet is for testing to avoid using the same name for the same machine for local testing, I used addr here
Lines 87 to 88 in 51708b5
Signed-off-by: husharp <ihusharp@gmail.com>
Signed-off-by: husharp <ihusharp@gmail.com>
Signed-off-by: husharp <ihusharp@gmail.com>
| "github.com/tikv/pd/pkg/utils/etcdutil" | ||
| "go.etcd.io/etcd/clientv3" | ||
| "go.uber.org/zap" | ||
| "strconv" |
There was a problem hiding this comment.
Need to check why our static doesn't detect it here. 🤔
Signed-off-by: husharp <ihusharp@gmail.com>
| // - changed by `{service}/primary/transfer` API. | ||
| // - leader lease expired. | ||
| // ONLY primary called this function. | ||
| func KeepExpectedPrimaryAlive(ctx context.Context, cli *clientv3.Client, exitPrimary chan struct{}, |
There was a problem hiding this comment.
| func KeepExpectedPrimaryAlive(ctx context.Context, cli *clientv3.Client, exitPrimary chan struct{}, | |
| func KeepExpectedPrimaryAlive(ctx context.Context, cli *clientv3.Client, exitPrimary chan<- struct{}, |
Signed-off-by: husharp <ihusharp@gmail.com>
| return | ||
| } | ||
| // ONLY `{service}/primary/transfer` API update primary will meet this condition. | ||
| if ev.Type == mvccpb.PUT && ls.IsPrimary() { |
There was a problem hiding this comment.
I think here we can optimize the case that if the updated primary is still itself, no need to return to campaign again.
There was a problem hiding this comment.
I skipped the member on the outer layer(in transfer primary) which is not the same as oldPrimary, do you think I still need to add the restriction inside the watch?
Maybe the expected primary flag should not be modified when the leader is itself, because this flag must keep the lease alive after campaigning new leader, which means that it requires the Primary to quit the current watch.
Signed-off-by: husharp <ihusharp@gmail.com>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JmPotato, rleungx The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: husharp <ihusharp@gmail.com>
|
Completed manual testing of operator and tiup |
|
/unhold |
|
@HuSharp: Your PR was out of date, I have automatically updated it for you. If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes. DetailsInstructions 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. |
What problem does this PR solve?
For tiup
We can upgrade pdms primary in last place(named defer feature) can avoid unnecessary primary transfer
Ref pingcap/tiup#2414
For operator
tidb-operator does not have the ability to
defer feature, it can only upgrade the pods in order.Furthermore, Thinking about this situation:
To fix it, Assume that current primary ordinal is x, and range is [0, n]
Ref pingcap/tidb-operator#5643
Issue Number: Close #7995, Ref #5766, #7519
What is changed and how does it work?
primaryWatchfor the primary watch only, which is used to reuseWatchinterface inLeadership.primaryWatchwatches/ms/primary/transferAPI whether changed the primary./ms/primary/transferAPI.leader_keyis deleted.expected_primaryis set before deleting theleader_key.expected_primaryfirstly,then delete theleader_keywhich will trigger the follower to campaign a new primary./ms/primary/transferAPI to change primarythe members info are
curl --location --request GET 'http://127.0.0.1:2379/pd/api/v2/ms/members/tso'get
[ { "name": "tso-0", "service-addr": "http://127.0.0.1:2384", "version": "v8.2.0-alpha-23-gdd72b9c19-dirty", "git-hash": "dd72b9c19707ccbdb1801d379b3982a7944df23f", "deploy-path": "/Users/pingcap/CS/PingCAP/pd/bin", "start-timestamp": 1715577605, "member-value": "ChtodHRwOi8vMTI3LjAuMC4xOjIzODQtMDAwMDAQp+L2iMCp3NUaGhVodHRwOi8vMTI3LjAuMC4xOjIzODQ=" }, { "name": "tso-1", "service-addr": "http://127.0.0.1:2386", "version": "v8.2.0-alpha-23-gdd72b9c19-dirty", "git-hash": "dd72b9c19707ccbdb1801d379b3982a7944df23f", "deploy-path": "/Users/pingcap/CS/PingCAP/pd/bin", "start-timestamp": 1715577605, "member-value": "ChtodHRwOi8vMTI3LjAuMC4xOjIzODYtMDAwMDAQj9ro5Yq9mY8mGhVodHRwOi8vMTI3LjAuMC4xOjIzODY=" } ]Check List
Tests
Release note