Skip to content

ddl: load cloud storage before picking add-index backfill#69733

Merged
ti-chi-bot[bot] merged 2 commits into
pingcap:masterfrom
D3Hunter:codex/fix-ddl-cloud-storage-backfill
Jul 9, 2026
Merged

ddl: load cloud storage before picking add-index backfill#69733
ti-chi-bot[bot] merged 2 commits into
pingcap:masterfrom
D3Hunter:codex/fix-ddl-cloud-storage-backfill

Conversation

@D3Hunter

@D3Hunter D3Hunter commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #69731

Problem Summary:

For distributed fast-reorg ADD INDEX with tidb_cloud_storage_uri configured, initForReorgIndexes picked the backfill type before loadCloudStorageURI populated job.ReorgMeta.UseCloudStorage. As a result, the ingest path could run the local disk precheck even though global-sort cloud storage should bypass local disk usage checks.

What changed and how does it work?

Load the cloud-storage URI before selecting the add-index backfill type during reorg initialization. This keeps job.ReorgMeta.UseCloudStorage as the existing source of truth for pickBackfillType, so cloud-storage/global-sort jobs select ingest backfill without touching local disk precheck.

A regression case was added to TestPickBackfillType with a disk root that fails if local precheck is reached. The test verifies a distributed fast-reorg job with cloud storage configured sets UseCloudStorage and selects ReorgTypeIngest.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Test commands:

./tools/check/failpoint-go-test.sh pkg/ddl -run TestPickBackfillType -count=1
./tools/check/failpoint-go-test.sh pkg/ddl -run TestPickBackfillType -count=1 -tags=intest,deadlock,nextgen
make lint
git diff --check

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

Fix an issue that ADD INDEX with global sort could fail due to a local ingest disk precheck before loading cloud storage configuration.

Summary by CodeRabbit

  • Bug Fixes
    • Improved index backfill behavior when cloud storage is configured, ensuring the cloud-backed ingest path is selected correctly.
    • Added coverage for cloud storage setups to skip unnecessary local disk prechecks, preventing avoidable test failures.

@ti-chi-bot ti-chi-bot Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 9, 2026
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e1fbacd9-5839-453d-9527-d4b7f718367f

📥 Commits

Reviewing files that changed from the base of the PR and between dbc8a91 and d6cbac6.

📒 Files selected for processing (1)
  • pkg/ddl/backfilling_test.go

📝 Walkthrough

Walkthrough

Moves cloud storage metadata loading ahead of backfill type selection in initForReorgIndexes, and adds a test that configures cloud storage with a failing local disk precheck to verify ingest selection still proceeds.

Changes

Cloud storage precheck ordering fix

Layer / File(s) Summary
Reorder loadCloudStorageURI before pickBackfillType
pkg/ddl/index.go
loadCloudStorageURI(w, job) is now called before pickBackfillType(job) in initForReorgIndexes, and the earlier later call site is removed.
Test skip of local precheck under cloud storage
pkg/ddl/backfilling_test.go
Adds a TestPickBackfillType subtest using testfailpoint to force the ingest environment check to fail, then verifies UseCloudStorage is set and ReorgTp becomes model.ReorgTypeIngest.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • pingcap/tidb#68558: Also changes how ReorgMeta.UseCloudStorage is used during DDL backfilling and reorg flow selection.
  • pingcap/tidb#69096: Also adjusts UseCloudStorage-driven backfill behavior in related DDL paths.

Suggested reviewers: joechenrh, wjhuang2016

Poem

I hopped past tmp space, one soft little bound,
Cloud storage loaded before checks came around.
With a failpoint in tow, the rabbit says “yay,”
Ingest takes the path and keeps going today. 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main behavior change: loading cloud storage before selecting add-index backfill.
Description check ✅ Passed The description includes the required issue number, change summary, tests, side effects, and release note, but the Problem Summary field is left blank.
Linked Issues check ✅ Passed The code loads cloud storage earlier and adds a regression test that matches the linked issue's expected fix.
Out of Scope Changes check ✅ Passed The changes stay focused on the reported ADD INDEX reorg ordering bug and its regression test.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="Running error: context loading failed: failed to load packages: failed to load packages: failed to load with go/packages: context deadline exceeded"
level=error msg="Timeout exceeded: try increasing it by passing --timeout option"


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@D3Hunter

D3Hunter commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

/cherry-pick release-nextgen-202603

@ti-chi-bot

Copy link
Copy Markdown
Member

@D3Hunter: once the present PR merges, I will cherry-pick it on top of release-nextgen-202603 in the new PR and assign it to you.

Details

In response to this:

/cherry-pick release-nextgen-202603

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.7447%. Comparing base (c22327f) to head (d6cbac6).
⚠️ Report is 13 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #69733        +/-   ##
================================================
- Coverage   76.3235%   75.7447%   -0.5789%     
================================================
  Files          2041       2079        +38     
  Lines        560482     585967     +25485     
================================================
+ Hits         427780     443839     +16059     
- Misses       131801     139299      +7498     
- Partials        901       2829      +1928     
Flag Coverage Δ
integration 45.9602% <100.0000%> (+6.2550%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 60.4471% <ø> (ø)
parser ∅ <ø> (∅)
br 63.8036% <ø> (+1.0822%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ingress-bot

Copy link
Copy Markdown

🔍 Starting code review for this PR...

@ingress-bot ingress-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review was generated by AI and should be verified by a human reviewer.
Manual follow-up is recommended before merge.

Summary

  • Total findings: 3
  • Inline comments: 1
  • Summary-only findings (no inline anchor): 2
Findings (highest risk first)

🟡 [Minor] (3)

  1. Ordering dependency between loadCloudStorageURI and pickBackfillType is undocumented (pkg/ddl/index.go:1359, pkg/ddl/index.go:1822, pkg/ddl/index.go:1851)
  2. New 8-method fake DiskRoot duplicates the existing PreCheckUsage failpoint hook (pkg/ddl/backfilling_test.go:134, pkg/ddl/ingest/disk_root.go:158)
  3. New test double breaks the package's mock/fake naming convention (pkg/ddl/backfilling_test.go:134)

Unanchored findings

🟡 [Minor] (2)

  1. New 8-method fake DiskRoot duplicates the existing PreCheckUsage failpoint hook
    • Request: Keep ingest.LitDiskRoot as the real diskRootImpl and enable the existing mockIngestCheckEnvFailed failpoint for the subtest instead of introducing a new fake type that must track the full DiskRoot interface.
  2. New test double breaks the package's mock/fake naming convention
    • Request: Rename to something like mockDiskRootWithFailedPreCheck (or mockFailingPreCheckDiskRoot) to keep the test-double naming convention consistent across pkg/ddl.

Comment thread pkg/ddl/index.go
@ti-chi-bot ti-chi-bot Bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jul 9, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: GMHDBJD, wjhuang2016

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jul 9, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-07-09 06:04:15.972843822 +0000 UTC m=+261642.008938888: ☑️ agreed by wjhuang2016.
  • 2026-07-09 06:52:43.103359268 +0000 UTC m=+264549.139454325: ☑️ agreed by GMHDBJD.

@D3Hunter

D3Hunter commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

/retest

2 similar comments
@D3Hunter

D3Hunter commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@D3Hunter

D3Hunter commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@ti-chi-bot
ti-chi-bot Bot merged commit d0dfde3 into pingcap:master Jul 9, 2026
37 checks passed
@ti-chi-bot

Copy link
Copy Markdown
Member

@D3Hunter: new pull request created to branch release-nextgen-202603: #69740.

Details

In response to this:

/cherry-pick release-nextgen-202603

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@D3Hunter
D3Hunter deleted the codex/fix-ddl-cloud-storage-backfill branch July 9, 2026 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Global sort ADD INDEX can fail on local ingest disk precheck before cloud storage is loaded

5 participants