-
Notifications
You must be signed in to change notification settings - Fork 14.7k
KAFKA-19682: Add logs for Kafka Streams task readiness #20693
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
lucliu1108
wants to merge
11
commits into
apache:trunk
Choose a base branch
from
lucliu1108:KAFKA-19682
base: trunk
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.
+40
−11
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ced1b22
add logs for task readiness
lucliu1108 69c6050
add more logs
lucliu1108 beafd37
remove redundant debug level info for log4j2
lucliu1108 c514cbd
fix spacing
lucliu1108 c60d7af
modify expected log output for tests
lucliu1108 2380789
Merge branch 'trunk' into KAFKA-19682
lucliu1108 ffecc92
revise
lucliu1108 d67ea53
revise
lucliu1108 a1cd730
reformat
lucliu1108 d0b0e82
add more logs to partitiongroup
lucliu1108 6105060
adjust logs
lucliu1108 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -445,7 +445,7 @@ public Map<TopicPartition, OffsetAndMetadata> prepareCommit(final boolean clean) | |
// TODO: this should be removed after we decouple caching with emitting | ||
flush(); | ||
if (!clean) { | ||
log.debug("Skipped preparing {} task with id {} for commit since the task is getting closed dirty.", state(), id); | ||
log.debug("Skipped preparing {} task for commit since the task is getting closed dirty.", state()); | ||
return null; | ||
} | ||
hasPendingTxCommit = eosEnabled; | ||
|
@@ -725,23 +725,26 @@ public boolean isProcessable(final long wallClockTime) { | |
// a task is only closing / closed when 1) task manager is closing, 2) a rebalance is undergoing; | ||
// in either case we can just log it and move on without notifying the thread since the consumer | ||
// would soon be updated to not return any records for this task anymore. | ||
log.info("Stream task {} is already in {} state, skip processing it.", id(), state()); | ||
log.info("Task is already in {} state, skip processing it.", state()); | ||
|
||
return false; | ||
} | ||
|
||
if (hasPendingTxCommit) { | ||
// if the task has a pending TX commit, we should just retry the commit but not process any records | ||
// thus, the task is not processable, even if there is available data in the record queue | ||
log.debug("Task has a pending transaction commit, skip processing it."); | ||
return false; | ||
} | ||
final boolean readyToProcess = partitionGroup.readyToProcess(wallClockTime); | ||
if (!readyToProcess) { | ||
if (timeCurrentIdlingStarted.isEmpty()) { | ||
timeCurrentIdlingStarted = Optional.of(wallClockTime); | ||
} | ||
log.debug("Task started idling at time {}", timeCurrentIdlingStarted.get()); | ||
} else { | ||
timeCurrentIdlingStarted = Optional.empty(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also add a "resumed" log similar to "started idling" ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added .Since this branch is called more often I set it to TRACE |
||
log.trace("Task is ready to process"); | ||
} | ||
return readyToProcess; | ||
} | ||
|
@@ -764,7 +767,10 @@ record = partitionGroup.nextRecord(recordInfo, wallClockTime); | |
|
||
// if there is no record to process, return immediately | ||
if (record == null) { | ||
log.trace("Task has no next record to process."); | ||
return false; | ||
} else { | ||
log.trace("Task fetched one record {} to process.", record); | ||
} | ||
} | ||
lucliu1108 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
@@ -773,15 +779,22 @@ record = partitionGroup.nextRecord(recordInfo, wallClockTime); | |
|
||
if (!(record instanceof CorruptedRecord)) { | ||
doProcess(wallClockTime); | ||
} else { | ||
log.trace("Task skips processing corrupted record {}", record); | ||
} | ||
|
||
// update the consumed offset map after processing is done | ||
consumedOffsets.put(partition, record.offset()); | ||
commitNeeded = true; | ||
|
||
log.trace("Task processed record: topic={}, partition={}, offset={}", | ||
record.topic(), record.partition(), record.offset()); | ||
|
||
// after processing this record, if its partition queue's buffered size has been | ||
// decreased to the threshold, we can then resume the consumption on this partition | ||
if (recordInfo.queue().size() <= maxBufferedSize) { | ||
log.trace("Resume consumption for partition {}: buffered size {} is under the threshold {}", | ||
partition, recordInfo.queue().size(), maxBufferedSize); | ||
partitionsToResume.add(partition); | ||
} | ||
|
||
lucliu1108 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
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
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.
Wondering if record be every be
null
here? -- Should we actually add anelse
and log an ERROR (or WARN) log, or even throwIllegalStateException
as this should always be true?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.
Record should not be
null
. If it is null then the queue itself is also empty (which is detected in the outer loop).I tried to add a else statement that throws an exception, and is detected by
SpotBugs
as "redundant null check". Therefore i think it's fine to drop it.