KAFKA-20404: Replace bulk TaskManager atomicity exclude with a field-level suppression#22340
Open
Phixsura wants to merge 1 commit into
Open
Conversation
…level suppression Removes TaskManager from the bulk Or block for AT_STALE_THREAD_WRITE_OF_PRIMITIVE and adds a targeted suppression for the single field SpotBugs flags, rebalanceInProgress. rebalanceInProgress is written from the ConsumerRebalanceListener callbacks (handleRebalanceStart / handleRebalanceComplete, invoked from KafkaConsumer.poll()) and read from StreamThread.runLoop and TaskManager's commit paths. All of these run on the StreamThread, so a stale cross-thread write cannot occur and the SpotBugs warning is a false positive. Third PR in the KAFKA-20404 series after StreamThread (apache#22320) and DefaultStateUpdater (apache#22333).
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.
Background
KAFKA-20404 tracks replacing the bulk SpotBugs atomicity excludes (introduced when SpotBugs was upgraded from 4.8.6 to 4.9.4) with per-field investigations. This PR handles
TaskManager, the third class in the series afterStreamThread(#22320) andDefaultStateUpdater(#22333).Investigation
After removing
TaskManagerfrom the single bulkAT_STALE_THREAD_WRITE_OF_PRIMITIVEblock it appeared in (trunk line 602), SpotBugs reports exactly one field with warnings:rebalanceInProgressatTaskManager.java:102, flagged at line 191 (handleRebalanceStart) and line 208 (handleRebalanceComplete).Walking the call sites:
handleRebalanceStart/handleRebalanceComplete) are invoked fromStreamsPartitionAssignorandDefaultStreamsRebalanceListener— both areConsumerRebalanceListenercallbacks fired from insideKafkaConsumer.poll(), which is driven by theStreamThread.rebalanceInProgress()getter happen atStreamThread.runLoop(lines 938 and 962).TaskManager.java:1883(maybeCommitActiveTasksPerUserRequested) andTaskManager.java:1897(commitTasksAndMaybeUpdateCommittableOffsets) are reached only fromTaskManager.commit(...)/StreamThread.runOnce*, which also run on theStreamThread.So
rebalanceInProgressis thread-confined to theStreamThread, and the SpotBugs warning is a false positive.Changes
TaskManagerfrom the bulk<Or>block.<Match>block scoped to the class plus therebalanceInProgressfield, with a rationale comment explaining the thread-confinement.Verification
:streams:spotbugsMain --rerun-tasksclean.:streams:spotbugsTest/:streams:checkstyleMain/:streams:checkstyleTestclean.:streams:test --tests "*TaskManager*"all green.