Repository navigation
Steal 1 lease from workers at target in lease count-based balancing - #1837
Merged
chenylee-aws merged 1 commit intoOct 28, 2026
Merged
Conversation
Match the KCL 2.x DynamoDBLeaseTaker rule: steal 1 lease when the worker needs more than 1 and the most loaded worker has exactly the target. Without this, a new worker gets no leases when all other workers are at the target.
jahyunk
requested a deployment
to
manual-approval
October 28, 2026 19:27 — with
GitHub Actions
Waiting
chenylee-aws
approved these changes
Oct 28, 2026
vincentvilo-aws
pushed a commit
to vincentvilo-aws/amazon-kinesis-client
that referenced
this pull request
Nov 3, 2026
…wslabs#1837) Match the KCL 2.x DynamoDBLeaseTaker rule: steal 1 lease when the worker needs more than 1 and the most loaded worker has exactly the target. Without this, a new worker gets no leases when all other workers are at the target.
vincentvilo-aws
added a commit
to vincentvilo-aws/amazon-kinesis-client
that referenced
this pull request
Nov 5, 2026
balanceWorkerVariance() returns early when getAssignableWorkers() is empty. The stubStorageView() helper, used by two tests added in awslabs#1837, didn't stub the assignable workers, so one test failed and the other passed without balancing. Stub them from the worker-to-leases map.
This branch is waiting to be deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue #, if available:
Description of changes:
With
LEASE_COUNT_BASEDassignment,LeaseCountBasedLeaseAssignmentDecider.balanceWorkerVariance()only moves a lease off a worker that holds more than the target. When every loaded worker holds exactly the target, a new worker gets no leases and stays at 0.Example from a production fleet: 21520 leases, 1215 active workers, target
ceil(21520 / 1215) = 18. 1193 workers hold 18, and 17 workers (including a newly deployed host) hold 0. The leader logsNo new lease assignment performed in this iterationon every run, so the new host never processes traffic.KCL 2.x did not have this gap.
DynamoDBLeaseTaker.chooseLeasesToStealsteals 1 lease when the worker needs more than 1 and the most loaded worker has exactly the target:This change applies the same rule in the two-pointer loop of
balanceWorkerVariance():excess == 0) gives 1 lease to a worker that needs more than 1 (needed > 1).leftpointer forward, so the remaining under-target workers are served in the same run.Unchanged:
neededis never above 1, so nothing changes.target - 1, so it does not take a lease back.Testing:
balanceWorkerVariance_allLoadedWorkersAtTarget_emptyWorkerStealsUpToTargetMinusOneandbalanceWorkerVariance_workerNeedsOnlyOneLease_noStealFromWorkersAtTarget.mvn -pl amazon-kinesis-client spotless:checkpasses.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.