Fix DynamoDBLeaseTaker
logging of available leases
#846
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.
When
DynamoDBLeaseTaker
is deciding what leases to take to satisfy the target lease-count of it's worker, it can take either expired leases that haven't been updated by any other worker for a while, or failing that, 'steal' a limited number (by default, 1) of leases from other workers, in order to ensure its worker is gradually getting closer to its target number.It turns out that the log message it prints out when taking expired leases is misleading. For instance, in this message - the leases weren't stolen, they were taken from the available 'expired' leases:
...yet the message says there were 0 available leases, so how is that possible? The truth is, there were 10 available expired leases, but the log message was printing out the value of
expiredLeases.size()
- andexpiredLeases
was mutated over the course of the method, with entries removed and added toleasesToTake
:amazon-kinesis-client/amazon-kinesis-client/src/main/java/software/amazon/kinesis/leases/dynamodb/DynamoDBLeaseTaker.java
Line 421 in 0c5042d
The fix to logging in this commit just records
numAvailableLeases
at the start of the method, so we can give an accurate log message:While I was investigating #845 I found the broken log messaging quite confusing!
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.