-
Notifications
You must be signed in to change notification settings - Fork 774
schedule: respect limits in concurrent patrol workers #10925
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
Open
rleungx
wants to merge
9
commits into
tikv:master
Choose a base branch
from
rleungx:patrol-region-worker-count-master-fix
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+147
−15
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e48894e
schedule: respect limits in concurrent patrol workers
rleungx 16c8144
schedule: clean up patrol operator admission
rleungx e946a88
tests: wait for affinity group visibility
rleungx 71fe19b
tests: avoid unused affinity wait result
rleungx c8040fa
tests: avoid assertions inside affinity wait loop
rleungx 7118142
schedule: report patrol pending work
rleungx 919f8c8
schedule: clarify patrol operator checks
rleungx 37d9c56
schedule: simplify patrol admission locking
rleungx 8e7ec80
schedule: account for merge candidate count
rleungx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The new coarse-grained
operatorMudoes fix the stale-count race between patrol workers, but I think the merge / affinity-merge boundary case is still not covered.CheckRegion()still only checksOperatorCount(OpMerge) < GetMergeScheduleLimit()before returning a merge pair. Since a merge candidate contains two operators,merge-schedule-limit = 3and currentOperatorCount(OpMerge) = 2can still admit another pair and end up with 4 merge operators.I verified this on the latest head with the following focused test, which fails because the final merge count becomes 4:
Could we either account for the candidate size when checking merge / affinity limits, or explicitly document that these limits may be exceeded by one pair?
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.
Fixed in 8e7ec80. Merge and affinity candidates now check their full candidate count against the remaining schedule-limit capacity (
candidateCount <= limit - current) before admission, so a pair is rejected when only one slot remains. I added the provided merge boundary regression plus focused capacity cases. Verified with the full checker package, the existing patrol replica-limit regression, focused race tests, andmake static.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.
I want to clarify my earlier suggestion here. The concern about merge candidates being different from single-operator candidates is still valid, but suggesting a strict
current + candidateCount <= limitcheck was too strict if we want to preserve the existing merge-pair semantics.The original issue this PR is fixing is the stale-count race between concurrent patrol workers. It is not necessarily trying to change the existing single-threaded behavior where one merge schedule produces two operators. Existing behavior/tests seem to allow one merge pair to be created when
merge-schedule-limit = 1, and existingTestPatrolRegionConcurrencyusesmergeScheduleLimit = 15and waits for at least 15 operators.With the current
len(ops)-based capacity check, an odd merge limit can stop below the configured limit. For example, withmerge-schedule-limit = 15, the merge checker can stop at 14 because the next merge pair has 2 operators. I verified this on the latest head by running:make gotest GOTEST_ARGS='./server/cluster -run TestPatrolRegionConcurrency -count=1 -timeout=2m'and
TestPatrolRegionConcurrencyfails because thelen(oc.GetOperators()) >= mergeScheduleLimitcondition is never satisfied.Could we preserve the existing merge-pair semantics while still serializing admission to avoid the concurrent stale-count overshoot? In other words, the admission lock should prevent multiple workers from racing on the same old count, but we probably should not make odd merge limits reject a whole pair before reaching the configured limit.