Skip to content

executor: remove unnecessary ordering from full-sampling Analyze requests - #70275

Open
0xPoe wants to merge 1 commit into
pingcap:masterfrom
0xPoe:poe/remove-analyze-keep-order
Open

executor: remove unnecessary ordering from full-sampling Analyze requests#70275
0xPoe wants to merge 1 commit into
pingcap:masterfrom
0xPoe:poe/remove-analyze-keep-order

Conversation

@0xPoe

@0xPoe 0xPoe commented Jul 31, 2026

Copy link
Copy Markdown
Member

What problem does this PR solve?

Issue Number: ref #63579, ref #70059

Problem Summary:

After #66772 removed Analyze v1 collection, full-sampling Analyze still requests ordered scans and splits unsigned-PK ranges at MaxInt64, although it sorts collected samples by handle before computing correlation.

What changed and how does it work?

  • Stop setting KeepOrder and scan both unsigned-handle ranges in one request.
  • Make Unistore continue when an earlier Analyze key range is empty.
  • Add focused coverage for request shape, boundary values, and empty leading ranges.

Extracted from #69686 and #70055; follow-up to #66772.

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.

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.

None

Summary by CodeRabbit

Bug Fixes

  • Improved V2 full-sampling analysis across unsigned integer boundaries.
  • Preserved correct sample ordering and histogram boundaries, including values around the signed integer limit.
  • Improved scan completion and result batching when analyzing multiple ranges.

Tests

  • Added regression coverage for boundary handling, empty ranges, and analysis request behavior.

Chores

  • Removed an unused test build dependency.

@ti-chi-bot ti-chi-bot Bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-triage-completed sig/planner SIG: Planner size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 31, 2026
@0xPoe

0xPoe commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

/retest

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

V2 full-sampling Analyze scans both unsigned boundary ranges in one unordered request and sorts samples by handle for correlation. Mock execution now fills chunks across multiple ranges. Regression coverage verifies boundary values and empty ranges. An unused Bazel dependency was removed.

Changes

Unsigned Handle Sampling

Layer / File(s) Summary
Analyze request behavior
pkg/executor/analyze_col.go, pkg/store/mockstore/unistore/cophandler/analyze.go
V2 full-sampling sends one unordered request, sorts samples by handle before correlation, and scans multiple ranges until the chunk is full or all ranges are complete.
Analyze behavior validation
pkg/executor/analyze_test.go, pkg/planner/core/casetest/planstats/BUILD.bazel
Failpoint instrumentation and regression tests verify one unordered request, unsigned boundaries at MaxInt64 and MaxInt64+1, empty unsigned ranges, and resulting row metadata. The test target removes an unused dependency.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested labels: component/statistics

Poem

Poem

A rabbit scans the ranges bright,
Across the signed boundary line.
One unordered request takes flight,
Sorted handles fall in time.
Tests guard each boundary true,
Empty ranges pass through too.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: removing unnecessary ordering from full-sampling Analyze requests.
Description check ✅ Passed The description includes issue references, problem context, implementation details, unit-test coverage, checklist selections, and a release-note entry.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@0xPoe
0xPoe force-pushed the poe/remove-analyze-keep-order branch 3 times, most recently from be804a7 to 6646dc7 Compare July 31, 2026 14:37
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 62.50000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.7856%. Comparing base (660d602) to head (3ba454c).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #70275        +/-   ##
================================================
- Coverage   76.3220%   73.7856%   -2.5365%     
================================================
  Files          2041       2060        +19     
  Lines        559145     580132     +20987     
================================================
+ Hits         426751     428054      +1303     
- Misses       131494     151670     +20176     
+ Partials        900        408       -492     
Flag Coverage Δ
integration 40.8852% <62.5000%> (+1.2189%) ⬆️

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

Components Coverage Δ
dumpling 59.8807% <ø> (ø)
parser ∅ <ø> (∅)
br 46.6234% <ø> (-16.0692%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@0xPoe
0xPoe force-pushed the poe/remove-analyze-keep-order branch from 6646dc7 to 90bd9a5 Compare July 31, 2026 15:00
@0xPoe

0xPoe commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

/test mysql-test

After the Analyze v1 collection path was removed, full-sampling Analyze sorts its V2 samples by handle before computing correlation. Stop preserving scan order and keep unsigned-handle ranges in one request.

Add request-shape coverage for the MaxInt64 boundary and regenerate Bazel metadata.

Signed-off-by: 0xPoe <poe.liu@pm.me>
@0xPoe
0xPoe force-pushed the poe/remove-analyze-keep-order branch from 90bd9a5 to 3ba454c Compare July 31, 2026 15:26
@0xPoe

0xPoe commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

/test pull-integration-realcluster-test-next-gen

@0xPoe 0xPoe left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

🔢 Self-check (PR reviewed by myself and ready for feedback)

  • Code compiles successfully

  • Unit tests added

  • No AI-generated elegant nonsense in PR.

  • Comments added where necessary

  • PR title and description updated

  • Documentation PR created (or confirmed not needed)

  • PR size is reasonable

/cc @terry1purcell @winoros

@ti-chi-bot
ti-chi-bot Bot requested review from terry1purcell and winoros July 31, 2026 16:29
@ti-chi-bot ti-chi-bot Bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 1, 2026

@winoros winoros left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice catch!

@ti-chi-bot

ti-chi-bot Bot commented Aug 1, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: terry1purcell, winoros

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

ti-chi-bot Bot commented Aug 1, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-08-01 00:56:02.695196772 +0000 UTC m=+2230348.731291828: ☑️ agreed by terry1purcell.
  • 2026-08-01 09:58:10.320727313 +0000 UTC m=+2262876.356822369: ☑️ agreed by winoros.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner 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.

3 participants