[SPARK-59662] Check for isRepartitionBatch can crash if metadata keys are missing - #58929
Open
ivasilyev1 wants to merge 2 commits into
Open
ivasilyev1 wants to merge 2 commits into
ivasilyev1 wants to merge 2 commits into
Conversation
Author
|
Please let me know if any changes are needed to conform with existing patterns as this is my first contribution to spark. Technically the changed files both independently prevent the crash from happening, but I figured that both changes made sense to include. |
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.
What changes were proposed in this pull request?
This PR changes 2 things:
OffsetSeqemit the rebinded SQLConf for bothOffsetSeqMetadataandOffsetSeqMetadataV2OfflineStateRepartitionUtils.isRepartitionBatchadd matched case to ensureshufflePartitionsandpreviousShufflePartitionsexistWhy are the changes needed?
These changes are necessary because in the current implementation
OfflineStateRepartitionUtils.isRepartitionBatchassumes thatspark.sql.shuffle.partitionswill always be present in the offset metadata and accesses the keys directly with.get.With the changes in offset log format v2, it is possible for the offset log to not contain this key if the current batch did not successfully complete. When this happens, the checks in
OfflineStateRepartitionUtils.isRepartitionBatchwill cause spark to crash:This behavior can be recreated with the following script to reliably trigger the crash:
Does this PR introduce any user-facing change?
I am unsure if this counts as a user-facing change, but the noticeable change would be that
spark.sql.shuffle.partitionskey is always present in the offset metadataHow was this patch tested?
I tested the crash condition with the above python script. After introducing these change and compiling a spark distribution, the query no longer crashes and instead finishes successfully
Was this patch authored or co-authored using generative AI tooling?
Generated-by: GPT 5.6-Luna