Skip to content

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

Open
ti-chi-bot wants to merge 2 commits into
pingcap:release-nextgen-202603from
ti-chi-bot:cherry-pick-69733-to-release-nextgen-202603
Open

ddl: load cloud storage before picking add-index backfill (#69733)#69740
ti-chi-bot wants to merge 2 commits into
pingcap:release-nextgen-202603from
ti-chi-bot:cherry-pick-69733-to-release-nextgen-202603

Conversation

@ti-chi-bot

@ti-chi-bot ti-chi-bot commented Jul 9, 2026

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #69733

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
    • Backfill operations now more reliably choose the correct processing mode when cloud storage is configured.
    • Improved handling of cloud-storage-backed reorganization so the system can select ingest-based processing as expected in supported scenarios.

@ti-chi-bot ti-chi-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. type/cherry-pick-for-release-nextgen-202603 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: ce39ead6-418c-4d7e-9334-91cb5446502f

📥 Commits

Reviewing files that changed from the base of the PR and between 1f6df34 and 64bb104.

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

📝 Walkthrough

Walkthrough

initForReorgIndexes in pkg/ddl/index.go now calls loadCloudStorageURI before pickBackfillType, removing the later duplicate call. A test file adds a subtest to TestPickBackfillType that verifies UseCloudStorage and ReorgTp are correctly set when a cloud storage URI is configured alongside an ingest-check failpoint.

Changes

Cloud Storage Load Ordering Fix

Layer / File(s) Summary
Reorder loadCloudStorageURI before pickBackfillType
pkg/ddl/index.go
loadCloudStorageURI(w, job) is now called immediately after the idxInfos guard, before pickBackfillType(job), and the later duplicate call before the merge-process branch is removed.
Test for cloud storage detection with ingest failpoint
pkg/ddl/backfilling_test.go
TestPickBackfillType gains a subtest that enables an ingest-check failpoint, sets vardef.CloudStorageURI, calls initForReorgIndexes, and asserts ReorgMeta.UseCloudStorage is true and ReorgTp is model.ReorgTypeIngest.

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

Possibly related PRs

  • pingcap/tidb#68558: Both PRs deal with job.ReorgMeta.UseCloudStorage propagation affecting backfill/streaming decisions.
  • pingcap/tidb#69096: Both PRs modify how UseCloudStorage is set and consumed by backfilling/reorg logic, including related failpoint testing.

Suggested labels: ok-to-test

Suggested reviewers: D3Hunter, joechenrh, GMHDBJD

Poem

A hop, a skip, a storage URI first,
Before the disk check quenches its thirst,
Now cloud paths load right in place,
No more failing at the ingest race,
This bunny thumps approval with delight! 🐇☁️

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: loading cloud storage before choosing add-index backfill.
Description check ✅ Passed The description follows the template with issue number, problem summary, changes, tests, side effects, and release note.
Linked Issues check ✅ Passed The changes match #69731 by loading cloud storage earlier so pickBackfillType can select ingest without local disk precheck.
Out of Scope Changes check ✅ Passed The diff is limited to the intended index backfill ordering fix and a regression test, with no obvious unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

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

D3Hunter commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

/retest

11 similar comments
@D3Hunter

D3Hunter commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

/retest

@D3Hunter

D3Hunter commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

/retest

@D3Hunter

D3Hunter commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

/retest

@D3Hunter

Copy link
Copy Markdown
Contributor

/retest

@D3Hunter

Copy link
Copy Markdown
Contributor

/retest

@D3Hunter

Copy link
Copy Markdown
Contributor

/retest

@D3Hunter

Copy link
Copy Markdown
Contributor

/retest

@D3Hunter

Copy link
Copy Markdown
Contributor

/retest

@D3Hunter

Copy link
Copy Markdown
Contributor

/retest

@D3Hunter

Copy link
Copy Markdown
Contributor

/retest

@D3Hunter

Copy link
Copy Markdown
Contributor

/retest

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (release-nextgen-202603@1f6df34). Learn more about missing BASE report.

Additional details and impacted files
@@                     Coverage Diff                     @@
##             release-nextgen-202603     #69740   +/-   ##
===========================================================
  Coverage                          ?   76.1428%           
===========================================================
  Files                             ?       1936           
  Lines                             ?     540765           
  Branches                          ?          0           
===========================================================
  Hits                              ?     411754           
  Misses                            ?     129011           
  Partials                          ?          0           
Flag Coverage Δ
unit 76.1428% <100.0000%> (?)

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

Components Coverage Δ
dumpling 61.5065% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 48.7626% <0.0000%> (?)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ti-chi-bot

ti-chi-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, joechenrh

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 13, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-07-09 14:28:40.6195639 +0000 UTC m=+291906.655658966: ☑️ agreed by D3Hunter.
  • 2026-07-13 08:58:47.233154247 +0000 UTC m=+617713.269249293: ☑️ agreed by joechenrh.

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. type/cherry-pick-for-release-nextgen-202603

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants