Fix NPE in HelixTaskExecutor.reset() when a task completes during shutdown - #3168
Open
Jackie-Jiang wants to merge 1 commit into
Open
Fix NPE in HelixTaskExecutor.reset() when a task completes during shutdown#3168Jackie-Jiang wants to merge 1 commit into
Jackie-Jiang wants to merge 1 commit into
Conversation
The final logging loop in reset() iterated _taskMap.keySet() and then called get(taskId) on the ConcurrentHashMap. A message task completing concurrently removes itself from the map between the two calls, so get returns null and reading info._task throws, failing the participant disconnect. Iterating entrySet() reads each entry atomically, so a concurrently-completing task is either logged or skipped, never null.
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.
Issues
Fixes #3167
Description
HelixTaskExecutor.reset()ends with a loop that logs tasks failing to terminate by iterating_taskMap.keySet()and then callingget(taskId)._taskMapis aConcurrentHashMapand message tasks remove themselves from it when they finish, so a task completing whilereset()runs disappears between the two calls:getreturns null and readinginfo._taskthrowswhich propagates out of
reset()and can fail the participant disconnect (observed intermittently in Apache Pinot integration-test teardowns).This change iterates
entrySet()instead: each entry is read atomically, so a concurrently-completing task is either logged or skipped, but can never yield a null value. No behavior change for tasks genuinely still present.Tests
None — the fix removes a data race in a shutdown logging loop; the race window (concurrent task completion between two map reads inside
reset()) is not deterministically reproducible from a unit test without intrusive instrumentation.Commits
Code Quality