KAFKA-20404: Replace bulk DefaultStateUpdater atomicity excludes with field-level suppressions#22333
Open
Phixsura wants to merge 1 commit into
Conversation
… field-level suppressions Removes DefaultStateUpdater$StateUpdaterThread from the bulk Or blocks for AT_NONATOMIC_OPERATIONS_ON_SHARED_VARIABLE and AT_NONATOMIC_64BIT_PRIMITIVE, and adds two targeted suppressions for the single field SpotBugs actually flags, totalCheckpointLatency. totalCheckpointLatency is accumulated in measureCheckpointLatency and reset in recordMetrics. Both methods are private and only invoked from within StateUpdaterThread.runOnce, so the read-modify-write is thread-confined and the SpotBugs warnings are false positives. Second PR in the KAFKA-20404 series after StreamThread (1/N, apache#22320).
Author
Thanks! Waiting for one more approval before merging. |
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
DefaultStateUpdater$StateUpdaterThread, the second class in the series afterStreamThread(#22320).Investigation
After removing
DefaultStateUpdater$StateUpdaterThreadfrom the two bulk excludes it appeared in (AT_NONATOMIC_OPERATIONS_ON_SHARED_VARIABLEat line 505 andAT_NONATOMIC_64BIT_PRIMITIVEat line 544 on trunk), SpotBugs reports exactly one field with warnings:totalCheckpointLatencyatDefaultStateUpdater.java:100, flagged at line 732 (measureCheckpointLatency) and line 750 (recordMetrics).Walking the call sites:
measureCheckpointLatencyisprivateand only called from withinStateUpdaterThread:restoreTasks,pauseTasks,resumeTasks,removeUpdatingTask,maybeCheckpointTasks.recordMetricsisprivateand only called fromStateUpdaterThread.runOnce(line 213).StateUpdaterThreaditself (the inner class extendsThread).So
totalCheckpointLatencyis thread-confined and the SpotBugs warnings are false positives.Changes
DefaultStateUpdater$StateUpdaterThreadfrom the two bulk<Or>blocks.<Match>blocks scoped to the class plus thetotalCheckpointLatencyfield, each with a rationale comment explaining the thread-confinement, one per bug pattern.Verification
:streams:spotbugsMain --rerun-tasksclean.:streams:checkstyleMain/:streams:checkstyleTest/:streams:spotbugsTestclean.:streams:test --tests "*DefaultStateUpdater*"all green.