← Back to Pull requests

[SPARK-54796][CORE] Fix NPE caused by race condition between Executor initialization and shuffle migration #54136

Closed
unknown closed this pull request without merging on Mar 10, 2026 03:44 UTC
View on GitHub
unknown unknown commented on Feb 04, 2026 09:22 UTC
Author

What changes were proposed in this pull request?


Fixing the race condition between executor initialization and shuffle migration. When starting an Executor, spark will:
  • Initialize blockManager, after this the block manager will be detected as peers of other node to receive shuffle blocks migration.

  • Then initialize shuffleManager.
  • Shuffle migration request could be received before shuffle manager is initialized, putBlockDataAsStream will be invoked and shuffleManager will be initialized as null.

    private lazy val shuffleManager = Option(_shuffleManager).getOrElse(SparkEnv.get.shuffleManager)
    

    Then all the later operations depending on shuffleManager will fail with NPE.

    To fix the issue, this PR propose to:
    1. Check whether shuffleManager is initialized when in putBlockDataAsStream which could be called before the Executor is fully ready to handle migration requests.
    2. If not ready, will wait until the specified timeout exceeds.
    3. The BlockManagerDecommissioner will retry if the shuffle migration request hits the issue timeout waiting for shuffleManager to be initialized.

    Why are the changes needed?


    Fixing the race condition leading to the shuffleManager in BlockManager to be initialized as null.

    Does this PR introduce _any_ user-facing change?


    No

    How was this patch tested?


    UT added.

    Was this patch authored or co-authored using generative AI tooling?


    Generated-by: Cursor 2.4.23

    Diff: 213 lines (+159 / -54) across 2 files Reviewer: Ngone51 Review duration: 48621m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.60) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.60 · 213 lines diff across 2 files
    0.60
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.321
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.060
    Real PR Conversation Timeline
    1 comments
    "Review active on #54136"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 59.7% (MEDIUM) · Higher = larger blast radius
    59.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 23.6% · Safe to merge
    23.6%
    Repository