Skip to content

*: clarify minimum max paging size semantics#67469

Merged
ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
D3Hunter:comment-cop
Mar 31, 2026
Merged

*: clarify minimum max paging size semantics#67469
ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
D3Hunter:comment-cop

Conversation

@D3Hunter
Copy link
Copy Markdown
Contributor

@D3Hunter D3Hunter commented Mar 31, 2026

What problem does this PR solve?

Issue Number: ref #61702

Problem Summary:
For next-gen coprocessor requests, storage can still return paging ranges even when paging is not explicitly enabled. The previous naming around MaxPagingSize did not clearly reflect its role as a lower bound for safe paging growth behavior.

What changed and how does it work?

  • Rename paging constant MaxPagingSize to MinAllowedMaxPagingSize to clarify semantics.
  • Keep a defensive floor in GrowPagingSize by enforcing max(maxv, MinAllowedMaxPagingSize).
  • Align default tidb_max_paging_size and request-builder test expectations with this lower bound.
  • Add clarifying comments in KV/coprocessor request handling about next-gen paging range behavior.

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

  • Tests

    • Updated paging configuration test cases with adjusted size constraints.
  • Documentation

    • Clarified paging behavior with next-gen coprocessor storage and response size control mechanisms.

@ti-chi-bot ti-chi-bot Bot added do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. labels Mar 31, 2026
@pantheon-ai
Copy link
Copy Markdown

pantheon-ai Bot commented Mar 31, 2026

@D3Hunter I've received your pull request and will start the review. I'll conduct a thorough review covering code quality, potential issues, and implementation details.

⏳ This process typically takes 10-30 minutes depending on the complexity of the changes.

ℹ️ Learn more details on Pantheon AI.

@ti-chi-bot ti-chi-bot Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 31, 2026
@tiprow
Copy link
Copy Markdown

tiprow Bot commented Mar 31, 2026

Hi @D3Hunter. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Details

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 kubernetes-sigs/prow repository.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 31, 2026

📝 Walkthrough

Walkthrough

The PR updates paging size constraint constants across the codebase, replacing MaxPagingSize with MinAllowedMaxPagingSize in configuration defaults, paging calculation logic, and test expectations. Documentation comments are also enhanced to clarify next-gen coprocessor paging behavior tied to response-size control.

Changes

Cohort / File(s) Summary
Core Paging Logic
pkg/util/paging/paging.go
Replaced MaxPagingSize constant with MinAllowedMaxPagingSize and updated GrowPagingSize and CalculateSeekCnt functions to use the new constraint; updated function comments and inline documentation to reflect the change.
Paging Tests
pkg/util/paging/paging_test.go
Updated test cases TestGrowPagingSize and TestCalculateSeekCnt to validate against MinAllowedMaxPagingSize instead of MaxPagingSize with adjusted boundary conditions.
Default Configuration
pkg/sessionctx/vardef/tidb_vars.go
Changed DefMaxPagingSize default value to use paging.MinAllowedMaxPagingSize instead of paging.MaxPagingSize.
Request Builder Tests
pkg/distsql/request_builder_test.go
Updated expected paging configuration in multiple test cases (TestRequestBuilder1, TestRequestBuilder2, TestRequestBuilder3, TestRequestBuilder4, TestRequestBuilder7, TestRequestBuilder8, TestRequestBuilderTiKVClientReadTimeout, TestRequestBuilderMaxExecutionTime) to expect paging.MinAllowedMaxPagingSize instead of paging.MaxPagingSize.
Documentation
pkg/kv/kv.go, pkg/store/copr/coprocessor.go
Enhanced comments in Request.Paging struct and copIteratorWorker.handleTaskOnce method to clarify next-gen coprocessor paging behavior and response-size control via max_resp_size (default 32MiB); no functional changes to signatures or control flow.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Suggested reviewers

  • wjhuang2016
  • YangKeao

Poem

🐰 A rabbit hops through paging code,
With MinAllowed on every road,
Constants dance and tests align,
Comments bloom—now paging's fine! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: renaming MaxPagingSize to MinAllowedMaxPagingSize and clarifying its role as a lower bound in paging semantics.
Description check ✅ Passed The PR description includes all major required sections: problem summary, what changed and how it works, test selection (unit test checked), side effects assessment, and release notes. The description is comprehensive and directly addresses the changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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.11.4)

Command failed


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 and usage tips.

@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Mar 31, 2026
Copy link
Copy Markdown
Contributor

@windtalker windtalker left a comment

Choose a reason for hiding this comment

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

lgtm

@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 31, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Mar 31, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-03-31 13:56:01.924576242 +0000 UTC m=+273367.129936289: ☑️ agreed by joechenrh.
  • 2026-03-31 13:56:53.566506193 +0000 UTC m=+273418.771866240: ☑️ agreed by windtalker.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
pkg/util/paging/paging.go (1)

58-58: Avoid hard-coding the seek-count base (8).

Line 58 hard-codes 8, which is implicitly maxPagingSizeShift + 1. Deriving it from constants keeps this stable if paging growth config changes later.

♻️ Proposed refactor
-		return float64(8 + (expectCnt-pagingGrowingSum+MinAllowedMaxPagingSize-1)/MinAllowedMaxPagingSize)
+		return float64(uint64(maxPagingSizeShift+1) + (expectCnt-pagingGrowingSum+MinAllowedMaxPagingSize-1)/MinAllowedMaxPagingSize)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/util/paging/paging.go` at line 58, The return expression currently
hard-codes the seek-count base as 8; replace that literal with a derived value
using the existing constant (maxPagingSizeShift + 1) so the computation becomes
stable when paging growth config changes—locate the return in
pkg/util/paging/paging.go (the expression returning float64(8 +
(expectCnt-pagingGrowingSum+MinAllowedMaxPagingSize-1)/MinAllowedMaxPagingSize))
and substitute 8 with (maxPagingSizeShift + 1), keeping the rest of the formula
intact and preserving types (cast to float64 as needed).
pkg/store/copr/coprocessor.go (2)

1768-1771: Polish the next-gen paging comment for clarity.

The intent is correct; just a small grammar/clarity cleanup would make this easier to scan.

✏️ Suggested comment wording
-// For next-gen, the storage may return paging range even if paging is not
-// enabled. coprocessor have a max_resp_size to control the response size,
-// the default is 32MiB
+// For next-gen requests, storage may return a paging range even when paging
+// is not explicitly enabled. Coprocessor response size is controlled by
+// max_resp_size (default: 32 MiB).
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/store/copr/coprocessor.go` around lines 1768 - 1771, Polish the comment
above the paging check in coprocessor: clarify that next-gen storage can return
a paging range even if paging isn't enabled, mention that the coprocessor
enforces a response size limit via max_resp_size (default 32MiB), and then leave
the conditional that checks worker.req.Paging.Enable || copResp.GetRange()
unchanged; replace the existing comment with a concise, grammatically-correct
sentence referencing the coprocessor, next-gen storage, paging range, and
max_resp_size so readers immediately understand why the check exists.

93-96: Improve wording for the memory warning comment.

Good intent, but the sentence is awkward (“this might be a large memory”). Consider tightening for readability.

✏️ Suggested comment wording
-// the returned kv.Response might hold at most concurrency * resp-channel-size
-// number of coprocessor responses depending on the request type, this might be
-// a large memory.
+// the returned kv.Response might hold up to
+// concurrency * resp-channel-size coprocessor responses (depending on request type),
+// which can consume a large amount of memory.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/store/copr/coprocessor.go` around lines 93 - 96, The existing comment
about memory usage is awkward; update the comment that references kv.Response
and the resp-channel-size (used by BuildCopIterator and buildCopTasks) to a
clearer phrasing such as: "The returned kv.Response may contain up to
concurrency * resp-channel-size coprocessor responses, which can consume a large
amount of memory depending on request type and channel sizes." Locate the
comment near BuildCopIterator/buildCopTasks and replace the sentence "this might
be a large memory" with this clearer wording.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/store/copr/coprocessor.go`:
- Around line 1768-1771: Polish the comment above the paging check in
coprocessor: clarify that next-gen storage can return a paging range even if
paging isn't enabled, mention that the coprocessor enforces a response size
limit via max_resp_size (default 32MiB), and then leave the conditional that
checks worker.req.Paging.Enable || copResp.GetRange() unchanged; replace the
existing comment with a concise, grammatically-correct sentence referencing the
coprocessor, next-gen storage, paging range, and max_resp_size so readers
immediately understand why the check exists.
- Around line 93-96: The existing comment about memory usage is awkward; update
the comment that references kv.Response and the resp-channel-size (used by
BuildCopIterator and buildCopTasks) to a clearer phrasing such as: "The returned
kv.Response may contain up to concurrency * resp-channel-size coprocessor
responses, which can consume a large amount of memory depending on request type
and channel sizes." Locate the comment near BuildCopIterator/buildCopTasks and
replace the sentence "this might be a large memory" with this clearer wording.

In `@pkg/util/paging/paging.go`:
- Line 58: The return expression currently hard-codes the seek-count base as 8;
replace that literal with a derived value using the existing constant
(maxPagingSizeShift + 1) so the computation becomes stable when paging growth
config changes—locate the return in pkg/util/paging/paging.go (the expression
returning float64(8 +
(expectCnt-pagingGrowingSum+MinAllowedMaxPagingSize-1)/MinAllowedMaxPagingSize))
and substitute 8 with (maxPagingSizeShift + 1), keeping the rest of the formula
intact and preserving types (cast to float64 as needed).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 17f864d0-a963-403c-b5cb-4576e55a05f7

📥 Commits

Reviewing files that changed from the base of the PR and between 6af045f and e49ff7e.

📒 Files selected for processing (6)
  • pkg/distsql/request_builder_test.go
  • pkg/kv/kv.go
  • pkg/sessionctx/vardef/tidb_vars.go
  • pkg/store/copr/coprocessor.go
  • pkg/util/paging/paging.go
  • pkg/util/paging/paging_test.go

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.5359%. Comparing base (1fef0d9) to head (e49ff7e).
⚠️ Report is 11 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #67469        +/-   ##
================================================
- Coverage   77.8038%   77.5359%   -0.2679%     
================================================
  Files          2023       1943        -80     
  Lines        556529     544724     -11805     
================================================
- Hits         433001     422357     -10644     
- Misses       121782     122359       +577     
+ Partials       1746          8      -1738     
Flag Coverage Δ
integration 41.1102% <40.0000%> (-7.0159%) ⬇️
unit 76.7447% <100.0000%> (+0.3766%) ⬆️

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

Components Coverage Δ
dumpling 61.5065% <ø> (ø)
parser ∅ <ø> (∅)
br 48.9283% <ø> (-11.9311%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ingress-bot
Copy link
Copy Markdown

🔍 Starting code review for this PR...

@ingress-bot
Copy link
Copy Markdown

🔍 New commits detected — starting re-review...

1 similar comment
@ingress-bot
Copy link
Copy Markdown

🔍 New commits detected — starting re-review...

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Mar 31, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: joechenrh, terry1purcell, windtalker

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 the approved label Mar 31, 2026
@terry1purcell
Copy link
Copy Markdown
Contributor

/retest-required

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Mar 31, 2026

@terry1purcell: PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test.

Details

In response to this:

/retest-required

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 kubernetes-sigs/prow repository.

@hawkingrei
Copy link
Copy Markdown
Member

/retest

@ti-chi-bot ti-chi-bot Bot merged commit 500f160 into pingcap:master Mar 31, 2026
35 checks passed
@D3Hunter D3Hunter deleted the comment-cop branch April 1, 2026 01:24
bitloi pushed a commit to bitloi/tidb that referenced this pull request Apr 2, 2026
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. 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.

6 participants