← Back to Pull requests

HIVE-30265: Table rename retried by RetryingHMSHandler leaves partitions at the old location #6967

Open
unknown opened this pull request with 234 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 18, 2026 06:51 UTC
Author

What changes were proposed in this pull request?


HiveAlterHandler.alterTable rewrites the location of the new table object passed in by the caller when it handles a rename that has to move data. This PR keeps the original value and restores it in the finally block when the transaction did not commit.

  • HiveAlterHandler: record the caller's location at the two places that rewrite it (managed table rename and translated-to-external table rename), and restore it before rollbackTransaction() on failure. The restore comes first because the rollback itself may throw.

  • TestAlterTableRenameWithHMSHandlerRetry: new test that fails the first alterPartitions call with a JDODataStoreException and checks the state after the retry.
  • Why are the changes needed?

    RetryingHMSHandler retries a failed call with the same argument objects. The rename flow is selected by comparing the old and the new table location:

    boolean renamedManagedTable = rename && ...
        && (oldt.getSd().getLocation().compareTo(newt.getSd().getLocation()) == 0
            || StringUtils.isEmpty(newt.getSd().getLocation()))
        && (!MetaStoreUtils.isExternalTable(oldt));
    

    After a first attempt that failed past newt.getSd().setLocation(destPath.toString()), the retry sees a location that differs from the old one and treats the call as a rename with a caller-specified location. It commits the new table name and table location, does not move the data and does not update partition locations, and returns success.

    The table keeps working because the partitions still point at the old directory. The damage comes later: once another table uses the old name, both tables share partition directories, and dropping the renamed managed table deletes the other table's data.

    Does this PR introduce _any_ user-facing change?


    No

    How was this patch tested?


    Add UT

    Diff: 234 lines (+175 / -59) across 2 files Reviewer: cxzl25 Review duration: 6409m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.37) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 234 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.327
    Real PR Conversation Timeline
    1 comments
    "Review active on #6967"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    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: 37.1% (MEDIUM) · Higher = larger blast radius
    37.1%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 19.8% · Safe to merge
    19.8%
    Repository