[SPARK-53435][SQL][3.5] Fix race condition in CachedRDDBuilder #52199
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.
What changes were proposed in this pull request?
backport 871fe3d
There is race condition between
CachedRDDBuilder.cachedColumnBuffers
andCachedRDDBuilder.clearCache
: when they interleave each other,cachedColumnBuffers
might return anullptr
.This looks like a day-1 bug introduced from 20ca208#diff-4068fce361a50e3d32af2ba2d4231905f500e7b2da9f46d5ddd99b758c30fd43
Why are the changes needed?
The race condition might lead to NPE from here which is basically a null
RDD
returned fromCachedRDDBuilder.cachedColumnBuffers
Does this PR introduce any user-facing change?
NO
How was this patch tested?
Theoretically this race condition might be triggered as long as cache materialization and unpersistence happen on different thread. But there is no reliable way to construct unit test.
Was this patch authored or co-authored using generative AI tooling?
NO