Skip to content

*: backport RC paging pre-charge to release-nextgen-202603 - #69830

Merged
ti-chi-bot[bot] merged 4 commits into
pingcap:release-nextgen-202603from
JmPotato:codex/rc-paging-precharge-release-nextgen-202603
Jul 20, 2026
Merged

ti-chi-bot[bot] merged 4 commits into
pingcap:release-nextgen-202603from
JmPotato:codex/rc-paging-precharge-release-nextgen-202603

Conversation

@JmPotato

@JmPotato JmPotato commented Jul 14, 2026 •

Copy link
Copy Markdown
Member

What problem does this PR solve?

Issue Number: ref #68085

Problem Summary:

Backport RC paging pre-charge to release-nextgen-202603. Without request-side pre-charge, concurrent paging coprocessor reads can consume a large amount of data before response settlement applies resource-control throttling. The paging gate must also use PD's effective runtime limited-burst state so service-limit overrides are not missed by static InfoSchema metadata. The earlier backport also left byte-budget paging disabled by default even for eligible non-burstable Resource Groups.

What changed and how does it work?

  • Add tidb_paging_size_bytes and forward the effective byte budget to TiKV coprocessor requests for eligible resource groups.
  • Add a per-logical-scan EMA that predicts paging response read bytes and sets client-go's PredictedReadBytes hint before dispatch.
  • Observe actual processed-version bytes after each paging response and expose paging pre-charge coverage, bytes, and residual metrics in the Resource Control Grafana dashboard.
  • Prefer PD's ResourceGroupRuntimeState.HasLimitedBurst when gating tidb_paging_size_bytes, with InfoSchema as the fallback until runtime state is available.
  • Default tidb_paging_size_bytes to 4 MiB for eligible non-burstable Resource Groups, declare its SET_VAR hint support inline, and document the tested performance rationale. Users can set it to 0 to disable byte-budget paging.
  • Preserve the release branch's Go 1.25.8 and dependency baseline. Master-only PD GC/metastorage API adaptations and unrelated Go, gRPC, and OpenTelemetry upgrades are intentionally excluded.

Dependencies:

Source PRs:

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.

Validated locally:

  • ./tools/check/failpoint-go-test.sh pkg/store/copr -run TestRUEMA -count=1
  • ./tools/check/failpoint-go-test.sh pkg/store/copr -run TestPagingResponseReadBytes -count=1
  • ./tools/check/failpoint-go-test.sh pkg/store/copr -run TestBuildCopTasksWithPagingSizeBytes -count=1
  • ./tools/check/failpoint-go-test.sh pkg/domain/infosync -run TestPutBundlesRetry -count=1
  • ./tools/check/failpoint-go-test.sh pkg/store/mockstore/unistore/tikv -run TestMockGCStatesManager -count=1
  • ./tools/check/failpoint-go-test.sh pkg/session -run TestDistSQLCtxPagingSizeBytesRequiresHardCappedResourceGroup -count=1
  • ./tools/check/failpoint-go-test.sh pkg/distsql -run TestRequestBuilderKeepsPagingSizeBytesWhenPagingDisabled -count=1
  • ./tools/check/failpoint-go-test.sh pkg/store/copr/copr_test -run TestBuildCopIteratorWithBatchStoreCopr -count=1
  • (cd tests/integrationtest && ./run-tests.sh -r sessionctx/setvar) (695 cases passed)
  • make bazel_prepare
  • make lint
  • git range-diff for each source/backport commit pair
  • git diff --check upstream/release-nextgen-202603...HEAD
image

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.

Resource control now pre-charges paging coprocessor reads with predicted read bytes before dispatch, tightening RU throttling for scans split across many paging RPCs. Paging recognizes PD's effective runtime limited-burst state. `tidb_paging_size_bytes` now defaults to 4 MiB for eligible non-burstable Resource Groups and can be set to `0` to disable byte-budget paging. The Resource Control Grafana dashboard adds paging pre-charge observability.

Summary by CodeRabbit

  • New Features

    • Added byte-budget paging for coprocessor requests through the tidb_paging_size_bytes session variable.
    • Enabled resource-control-aware paging with a default budget of 4 MiB.
    • Added adaptive read-size estimation to improve paging behavior.
    • Added Grafana panels for paging pre-charge coverage, bytes, and prediction accuracy.
  • Bug Fixes

    • Preserved paging configuration consistently across requests and cache operations.
    • Disabled byte-budget paging for unsupported request types.

@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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 14, 2026
@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds tidb_paging_size_bytes configuration, propagates byte-budget paging through DistSQL and coprocessor requests, introduces EMA-based read-byte prediction, updates cache behavior and tests, adds Grafana panels, and refreshes dependency pins.

Changes

Paging configuration and propagation

Layer / File(s) Summary
Session variable and eligibility
pkg/sessionctx/vardef/tidb_vars.go, pkg/sessionctx/variable/*, pkg/session/session.go, pkg/session/tidb_test.go
Adds the tidb_paging_size_bytes variable with a 4 MiB default and enables it only for eligible resource groups when Resource Control is active.
DistSQL and KV request wiring
pkg/distsql/context/*, pkg/distsql/distsql.go, pkg/distsql/request_builder*, pkg/kv/kv.go, pkg/executor/distsql.go
Adds byte-budget fields and forwards them into KV paging requests while preserving the value when row-count paging is disabled.
Variable and propagation validation
tests/integrationtest/sessionctx/setvar.*, pkg/distsql/BUILD.bazel
Tests variable assignment, defaults, zero values, and updated test sharding.

Coprocessor byte-budget execution

Layer / File(s) Summary
EMA prediction model
pkg/store/copr/ema.go, pkg/store/copr/ema_test.go
Adds a concurrency-safe, time-aware EMA for predicting paging read bytes and tests convergence, workload shifts, time gaps, concurrency, and response-byte selection.
Paging request execution
pkg/store/copr/coprocessor.go, pkg/store/copr/copr_test/coprocessor_test.go, pkg/store/copr/BUILD.bazel
Supports byte-budget paging for TiKV DAG requests, sends predicted bytes, observes returned bytes, updates paging task handling, and disables incompatible store batching.
Paging cache behavior
pkg/store/copr/coprocessor_cache.go, pkg/store/copr/coprocessor_cache_test.go
Marks byte-budget requests in cache keys and restores cached paging ranges, with coverage for key encoding and cache hits.

Paging pre-charge dashboards

Layer / File(s) Summary
Resource-control dashboards
pkg/metrics/grafana/tidb_resource_control.*, pkg/metrics/nextgengrafana/tidb_resource_control_with_keyspace_name.*
Adds Paging Pre-charge rows showing pre-charge coverage, predicted versus actual bytes, and prediction residual quantiles with stable panel IDs.

Dependency metadata

Layer / File(s) Summary
Go and Bazel dependency pins
go.mod, DEPS.bzl
Advances the kvproto, client-go, and PD client versions and updates their Bazel integrity metadata.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Session
  participant DistSQL
  participant Coprocessor
  participant TiKV
  Session->>DistSQL: Set PagingSizeBytes
  DistSQL->>Coprocessor: Build byte-budget request
  Coprocessor->>TiKV: Send predicted read bytes
  TiKV-->>Coprocessor: Return page and observed read bytes
  Coprocessor->>Coprocessor: Update EMA
Loading

Possibly related PRs

Suggested reviewers: cfzjywx, rleungx, yudongusa

Poem

I’m a rabbit with bytes in my pack,
Paging predictions hop down the track.
EMA learns each read,
Dashboards show what we need,
While fresh pins keep the burrow on track.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.13% 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
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 describes the backport of RC paging pre-charge to the release-nextgen-202603 branch.
Description check ✅ Passed The description covers the issue, problem summary, changes, tests, side effects, docs, and release note with the required sections.
✨ 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.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
pkg/store/copr/ema.go (1)

37-57: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Avoid relying on implicit time.Sub clamping and extreme float64 bounds.

The current design leaves lastObsAt as the zero time, relying on now.Sub(zeroTime) to overflow and be clamped by Go's time package to math.MaxInt64. This results in math.Exp(-huge) underflowing to 0.0, yielding an alpha of exactly 1.0 to seamlessly replace the seed value.

While functionally correct and clever, relying on edge-case arithmetic and implicit bounds clamping is non-obvious and brittle. Using an explicit IsZero() check achieves the exact same result while clarifying the intent for future maintainers.

♻️ Proposed refactor
-func newRUEMA(seedReadBytes uint64) *ruEMA {
-	// lastObsAt is intentionally left as the zero time. If there is no seed,
-	// the first Observe gets alpha ~= 1 and seeds value from the first sample;
-	// if there is a byte-budget seed, the first real sample replaces it.
-	return &ruEMA{tau: defaultRUEMATau, value: float64(seedReadBytes)}
-}
-
-func (e *ruEMA) Observe(bytes uint64, now time.Time) {
-	e.mu.Lock()
-	defer e.mu.Unlock()
-	dt := now.Sub(e.lastObsAt)
-	if dt < 0 {
-		dt = 0
-	}
-	alpha := 1 - math.Exp(-float64(dt)/float64(e.tau))
-	e.value += alpha * (float64(bytes) - e.value)
-	// Don't rewind on out-of-order Observes.
-	if now.After(e.lastObsAt) {
-		e.lastObsAt = now
-	}
-}
+func newRUEMA(seedReadBytes uint64) *ruEMA {
+	// If there is a byte-budget seed, the first real sample replaces it.
+	return &ruEMA{tau: defaultRUEMATau, value: float64(seedReadBytes)}
+}
+
+func (e *ruEMA) Observe(bytes uint64, now time.Time) {
+	e.mu.Lock()
+	defer e.mu.Unlock()
+
+	if e.lastObsAt.IsZero() {
+		e.value = float64(bytes)
+		e.lastObsAt = now
+		return
+	}
+
+	dt := now.Sub(e.lastObsAt)
+	if dt < 0 {
+		dt = 0
+	}
+	alpha := 1 - math.Exp(-float64(dt)/float64(e.tau))
+	e.value += alpha * (float64(bytes) - e.value)
+	// Don't rewind on out-of-order Observes.
+	if now.After(e.lastObsAt) {
+		e.lastObsAt = now
+	}
+}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/store/copr/ema.go` around lines 37 - 57, Update ruEMA.Observe to
explicitly detect an unset e.lastObsAt with IsZero() and use alpha 1 for that
first observation, avoiding time.Sub on the zero timestamp and extreme float64
calculations; preserve the existing non-zero timestamp decay and out-of-order
timestamp behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pkg/store/copr/ema.go`:
- Around line 37-57: Update ruEMA.Observe to explicitly detect an unset
e.lastObsAt with IsZero() and use alpha 1 for that first observation, avoiding
time.Sub on the zero timestamp and extreme float64 calculations; preserve the
existing non-zero timestamp decay and out-of-order timestamp behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d0f82cb3-fcd6-4c1a-8297-ced7640fa15d

📥 Commits

Reviewing files that changed from the base of the PR and between b071dee and 1f34ec1.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (41)
  • DEPS.bzl
  • Dockerfile
  • Dockerfile.enterprise
  • WORKSPACE
  • build/image/base
  • build/image/parser_test
  • go.mod
  • pkg/distsql/BUILD.bazel
  • pkg/distsql/context/context.go
  • pkg/distsql/context/context_test.go
  • pkg/distsql/distsql.go
  • pkg/distsql/request_builder.go
  • pkg/distsql/request_builder_test.go
  • pkg/domain/infosync/BUILD.bazel
  • pkg/domain/infosync/resource_manager_client.go
  • pkg/executor/adapter_internal_test.go
  • pkg/executor/distsql.go
  • pkg/kv/kv.go
  • pkg/metrics/grafana/tidb_resource_control.json
  • pkg/metrics/grafana/tidb_resource_control.jsonnet
  • pkg/metrics/nextgengrafana/tidb_resource_control_with_keyspace_name.json
  • pkg/metrics/nextgengrafana/tidb_resource_control_with_keyspace_name.jsonnet
  • pkg/session/session.go
  • pkg/session/tidb_test.go
  • pkg/sessionctx/vardef/tidb_vars.go
  • pkg/sessionctx/variable/session.go
  • pkg/sessionctx/variable/setvar_affect.go
  • pkg/sessionctx/variable/sysvar.go
  • pkg/store/copr/BUILD.bazel
  • pkg/store/copr/batch_coprocessor.go
  • pkg/store/copr/copr_test/coprocessor_test.go
  • pkg/store/copr/coprocessor.go
  • pkg/store/copr/coprocessor_cache.go
  • pkg/store/copr/coprocessor_cache_test.go
  • pkg/store/copr/coprocessor_test.go
  • pkg/store/copr/ema.go
  • pkg/store/copr/ema_test.go
  • pkg/store/mockstore/unistore/pd.go
  • pkg/store/mockstore/unistore/tikv/mock_region.go
  • tests/integrationtest/r/sessionctx/setvar.result
  • tests/integrationtest/t/sessionctx/setvar.test

@JmPotato
JmPotato force-pushed the codex/rc-paging-precharge-release-nextgen-202603 branch from 8177424 to 46cbdfe Compare July 15, 2026 09:34

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (4)
pkg/store/mockstore/unistore/pd.go (1)

438-440: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Prefer cmp.Compare over manual type conversion and subtraction.

Using cmp.Compare from the standard cmp package is safer and more idiomatic. It prevents potential integer overflow issues on 32-bit architectures where int is 32 bits, which could occur when subtracting large uint32 values.

♻️ Proposed refactor
-	index, exists := slices.BinarySearchFunc(m.keyspaces, id, func(k *keyspacepb.KeyspaceMeta, idToSearch uint32) int {
-		return int(k.Id) - int(idToSearch)
-	})
+	index, exists := slices.BinarySearchFunc(m.keyspaces, id, func(k *keyspacepb.KeyspaceMeta, idToSearch uint32) int {
+		return cmp.Compare(k.Id, idToSearch)
+	})

Note: Make sure to add "cmp" to the imports if it is not already imported.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/store/mockstore/unistore/pd.go` around lines 438 - 440, Update the
comparison function passed to slices.BinarySearchFunc in the keyspace lookup to
use cmp.Compare with the uint32 keyspace ID and idToSearch values, avoiding
manual int conversion and subtraction. Add the standard cmp import if needed.
pkg/store/copr/coprocessor_test.go (1)

713-717: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Prefer assert.NoError over require.NoError inside defer.

Using require.NoError inside a defer is unsafe because it calls t.FailNow() (which triggers runtime.Goexit()) on failure. If the test is already panicking or failing, this will abruptly terminate the goroutine and swallow the original panic or error trace, making debugging difficult. Consider using assert.NoError instead.

♻️ Proposed refactor
 	defer func() {
 		pdClient.Close()
 		err = mockClient.Close()
-		require.NoError(t, err)
+		assert.NoError(t, err)
 	}()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/store/copr/coprocessor_test.go` around lines 713 - 717, In the deferred
cleanup block, replace require.NoError with assert.NoError when checking
mockClient.Close(). Keep the existing pdClient.Close() cleanup and error
assignment unchanged, ensuring cleanup failures do not terminate the test
goroutine or mask the original failure.
pkg/store/copr/ema_test.go (1)

124-128: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Test both configurations if NextGen is mutable.

This assertion only tests the behavior corresponding to the current global state of clientgoconfig.NextGen. Consequently, the inactive branch is left untested in a given test run.

If NextGen is a mutable variable, consider toggling its state to explicitly guarantee coverage for both the classic and next-gen pathways.

💡 Proposed refactor to test both code paths
-			want := tt.classicWant
-			if clientgoconfig.NextGen {
-				want = tt.nextGenWant
-			}
-			require.Equal(t, want, pagingResponseReadBytes(resp))
+			// Save the original state and restore it after testing.
+			originalNextGen := clientgoconfig.NextGen
+			defer func() { clientgoconfig.NextGen = originalNextGen }()
+
+			// Test classic behavior
+			clientgoconfig.NextGen = false
+			require.Equal(t, tt.classicWant, pagingResponseReadBytes(resp))
+
+			// Test NextGen behavior
+			clientgoconfig.NextGen = true
+			require.Equal(t, tt.nextGenWant, pagingResponseReadBytes(resp))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/store/copr/ema_test.go` around lines 124 - 128, Update the test around
pagingResponseReadBytes to explicitly exercise both clientgoconfig.NextGen
states rather than selecting one expected value from the current global state.
Toggle NextGen for separate classic and next-gen assertions, restoring the
original state afterward, and use classicWant and nextGenWant respectively.
pkg/store/copr/ema.go (1)

37-57: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use an explicit IsZero check for the first observation.

Relying on now.Sub(time.Time{}) to produce a massive dt and yield alpha ≈ 1 is an elegant trick, but it can be fragile. If a unit test environment mocks time to be near the Unix epoch, the calculated dt will be smaller, alpha will not equal 1.0, and the seed value will unexpectedly leak into the first real sample's calculation.

Consider explicitly checking for the uninitialized state to make the code robust against any time value.

💡 Proposed refactor to explicitly handle the first observation
 func newRUEMA(seedReadBytes uint64) *ruEMA {
-	// lastObsAt is intentionally left as the zero time. If there is no seed,
-	// the first Observe gets alpha ~= 1 and seeds value from the first sample;
-	// if there is a byte-budget seed, the first real sample replaces it.
+	// lastObsAt is intentionally left as the zero time to signal the first
+	// Observe to completely replace the initial seed value with the first sample.
 	return &ruEMA{tau: defaultRUEMATau, value: float64(seedReadBytes)}
 }
 
 func (e *ruEMA) Observe(bytes uint64, now time.Time) {
 	e.mu.Lock()
 	defer e.mu.Unlock()
+
+	if e.lastObsAt.IsZero() {
+		e.value = float64(bytes)
+		e.lastObsAt = now
+		return
+	}
+
 	dt := now.Sub(e.lastObsAt)
 	if dt < 0 {
 		dt = 0
 	}
 	alpha := 1 - math.Exp(-float64(dt)/float64(e.tau))
 	e.value += alpha * (float64(bytes) - e.value)
 	// Don't rewind on out-of-order Observes.
 	if now.After(e.lastObsAt) {
 		e.lastObsAt = now
 	}
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/store/copr/ema.go` around lines 37 - 57, Update ruEMA.Observe to
explicitly detect an uninitialized lastObsAt with IsZero before calculating dt
and alpha; on the first observation, replace the seeded value with the sample
directly and initialize lastObsAt, while preserving the existing smoothing and
out-of-order timestamp behavior for subsequent observations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pkg/store/copr/coprocessor_test.go`:
- Around line 713-717: In the deferred cleanup block, replace require.NoError
with assert.NoError when checking mockClient.Close(). Keep the existing
pdClient.Close() cleanup and error assignment unchanged, ensuring cleanup
failures do not terminate the test goroutine or mask the original failure.

In `@pkg/store/copr/ema_test.go`:
- Around line 124-128: Update the test around pagingResponseReadBytes to
explicitly exercise both clientgoconfig.NextGen states rather than selecting one
expected value from the current global state. Toggle NextGen for separate
classic and next-gen assertions, restoring the original state afterward, and use
classicWant and nextGenWant respectively.

In `@pkg/store/copr/ema.go`:
- Around line 37-57: Update ruEMA.Observe to explicitly detect an uninitialized
lastObsAt with IsZero before calculating dt and alpha; on the first observation,
replace the seeded value with the sample directly and initialize lastObsAt,
while preserving the existing smoothing and out-of-order timestamp behavior for
subsequent observations.

In `@pkg/store/mockstore/unistore/pd.go`:
- Around line 438-440: Update the comparison function passed to
slices.BinarySearchFunc in the keyspace lookup to use cmp.Compare with the
uint32 keyspace ID and idToSearch values, avoiding manual int conversion and
subtraction. Add the standard cmp import if needed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6574ebbd-d795-4125-b23a-040686408835

📥 Commits

Reviewing files that changed from the base of the PR and between 8177424 and 46cbdfe.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (41)
  • DEPS.bzl
  • Dockerfile
  • Dockerfile.enterprise
  • WORKSPACE
  • build/image/base
  • build/image/parser_test
  • go.mod
  • pkg/distsql/BUILD.bazel
  • pkg/distsql/context/context.go
  • pkg/distsql/context/context_test.go
  • pkg/distsql/distsql.go
  • pkg/distsql/request_builder.go
  • pkg/distsql/request_builder_test.go
  • pkg/domain/infosync/BUILD.bazel
  • pkg/domain/infosync/resource_manager_client.go
  • pkg/executor/adapter_internal_test.go
  • pkg/executor/distsql.go
  • pkg/kv/kv.go
  • pkg/metrics/grafana/tidb_resource_control.json
  • pkg/metrics/grafana/tidb_resource_control.jsonnet
  • pkg/metrics/nextgengrafana/tidb_resource_control_with_keyspace_name.json
  • pkg/metrics/nextgengrafana/tidb_resource_control_with_keyspace_name.jsonnet
  • pkg/session/session.go
  • pkg/session/tidb_test.go
  • pkg/sessionctx/vardef/tidb_vars.go
  • pkg/sessionctx/variable/session.go
  • pkg/sessionctx/variable/setvar_affect.go
  • pkg/sessionctx/variable/sysvar.go
  • pkg/store/copr/BUILD.bazel
  • pkg/store/copr/batch_coprocessor.go
  • pkg/store/copr/copr_test/coprocessor_test.go
  • pkg/store/copr/coprocessor.go
  • pkg/store/copr/coprocessor_cache.go
  • pkg/store/copr/coprocessor_cache_test.go
  • pkg/store/copr/coprocessor_test.go
  • pkg/store/copr/ema.go
  • pkg/store/copr/ema_test.go
  • pkg/store/mockstore/unistore/pd.go
  • pkg/store/mockstore/unistore/tikv/mock_region.go
  • tests/integrationtest/r/sessionctx/setvar.result
  • tests/integrationtest/t/sessionctx/setvar.test
🚧 Files skipped from review as they are similar to previous changes (30)
  • Dockerfile.enterprise
  • pkg/distsql/BUILD.bazel
  • pkg/distsql/context/context_test.go
  • build/image/base
  • build/image/parser_test
  • Dockerfile
  • tests/integrationtest/r/sessionctx/setvar.result
  • WORKSPACE
  • pkg/store/copr/BUILD.bazel
  • pkg/sessionctx/vardef/tidb_vars.go
  • pkg/store/mockstore/unistore/tikv/mock_region.go
  • tests/integrationtest/t/sessionctx/setvar.test
  • pkg/sessionctx/variable/setvar_affect.go
  • pkg/domain/infosync/BUILD.bazel
  • pkg/sessionctx/variable/session.go
  • pkg/sessionctx/variable/sysvar.go
  • pkg/session/session.go
  • pkg/distsql/request_builder.go
  • pkg/kv/kv.go
  • pkg/domain/infosync/resource_manager_client.go
  • pkg/metrics/grafana/tidb_resource_control.json
  • pkg/metrics/nextgengrafana/tidb_resource_control_with_keyspace_name.jsonnet
  • pkg/store/copr/coprocessor_cache.go
  • pkg/metrics/grafana/tidb_resource_control.jsonnet
  • pkg/store/copr/coprocessor_cache_test.go
  • go.mod
  • pkg/session/tidb_test.go
  • pkg/distsql/request_builder_test.go
  • pkg/metrics/nextgengrafana/tidb_resource_control_with_keyspace_name.json
  • pkg/store/copr/coprocessor.go

@codecov

codecov Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.97590% with 5 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release-nextgen-202603@86c5dc7). Learn more about missing BASE report.

Additional details and impacted files
@@                     Coverage Diff                     @@
##             release-nextgen-202603     #69830   +/-   ##
===========================================================
  Coverage                          ?   76.1812%           
===========================================================
  Files                             ?       1937           
  Lines                             ?     541091           
  Branches                          ?          0           
===========================================================
  Hits                              ?     412210           
  Misses                            ?     128881           
  Partials                          ?          0           
Flag Coverage Δ
unit 76.1812% <93.9759%> (?)

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.7418% <0.0000%> (?)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JmPotato
JmPotato force-pushed the codex/rc-paging-precharge-release-nextgen-202603 branch from 85a15b9 to 0d73446 Compare July 16, 2026 13:32

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
pkg/store/copr/ema_test.go (1)

124-128: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Test both configurations for pagingResponseReadBytes.

The test currently only exercises one branch of the logic depending on the runtime environment's value of clientgoconfig.NextGen. If NextGen is a mutable global variable, consider iterating over both boolean states and overriding it during the test to ensure that both the classic and next-gen paths are deterministically verified in CI.

💡 Proposed refactor
-			want := tt.classicWant
-			if clientgoconfig.NextGen {
-				want = tt.nextGenWant
-			}
-			require.Equal(t, want, pagingResponseReadBytes(resp))
+			for _, nextGen := range []bool{false, true} {
+				t.Run(fmt.Sprintf("NextGen=%v", nextGen), func(t *testing.T) {
+					originalNextGen := clientgoconfig.NextGen
+					clientgoconfig.NextGen = nextGen
+					t.Cleanup(func() { clientgoconfig.NextGen = originalNextGen })
+
+					want := tt.classicWant
+					if nextGen {
+						want = tt.nextGenWant
+					}
+					require.Equal(t, want, pagingResponseReadBytes(resp))
+				})
+			}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/store/copr/ema_test.go` around lines 124 - 128, Update the test around
pagingResponseReadBytes to run deterministically with clientgoconfig.NextGen set
to both false and true, selecting the matching classicWant or nextGenWant
expectation for each case. Restore the original global value after the test,
including when assertions fail, and preserve the existing response setup and
equality checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pkg/store/copr/ema_test.go`:
- Around line 124-128: Update the test around pagingResponseReadBytes to run
deterministically with clientgoconfig.NextGen set to both false and true,
selecting the matching classicWant or nextGenWant expectation for each case.
Restore the original global value after the test, including when assertions
fail, and preserve the existing response setup and equality checks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 748689b6-6703-4bc8-bf60-d7d9512cb776

📥 Commits

Reviewing files that changed from the base of the PR and between 46cbdfe and 0d73446.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (30)
  • DEPS.bzl
  • go.mod
  • pkg/distsql/BUILD.bazel
  • pkg/distsql/context/context.go
  • pkg/distsql/context/context_test.go
  • pkg/distsql/distsql.go
  • pkg/distsql/request_builder.go
  • pkg/distsql/request_builder_test.go
  • pkg/executor/distsql.go
  • pkg/kv/kv.go
  • pkg/metrics/grafana/tidb_resource_control.json
  • pkg/metrics/grafana/tidb_resource_control.jsonnet
  • pkg/metrics/nextgengrafana/tidb_resource_control_with_keyspace_name.json
  • pkg/metrics/nextgengrafana/tidb_resource_control_with_keyspace_name.jsonnet
  • pkg/session/session.go
  • pkg/session/tidb_test.go
  • pkg/sessionctx/vardef/tidb_vars.go
  • pkg/sessionctx/variable/session.go
  • pkg/sessionctx/variable/setvar_affect.go
  • pkg/sessionctx/variable/sysvar.go
  • pkg/store/copr/BUILD.bazel
  • pkg/store/copr/copr_test/coprocessor_test.go
  • pkg/store/copr/coprocessor.go
  • pkg/store/copr/coprocessor_cache.go
  • pkg/store/copr/coprocessor_cache_test.go
  • pkg/store/copr/coprocessor_test.go
  • pkg/store/copr/ema.go
  • pkg/store/copr/ema_test.go
  • tests/integrationtest/r/sessionctx/setvar.result
  • tests/integrationtest/t/sessionctx/setvar.test
🚧 Files skipped from review as they are similar to previous changes (20)
  • pkg/distsql/BUILD.bazel
  • pkg/sessionctx/variable/session.go
  • tests/integrationtest/t/sessionctx/setvar.test
  • pkg/distsql/context/context.go
  • pkg/sessionctx/variable/setvar_affect.go
  • pkg/sessionctx/variable/sysvar.go
  • pkg/sessionctx/vardef/tidb_vars.go
  • pkg/distsql/distsql.go
  • pkg/store/copr/coprocessor_cache_test.go
  • pkg/store/copr/copr_test/coprocessor_test.go
  • pkg/distsql/request_builder.go
  • pkg/session/session.go
  • pkg/distsql/request_builder_test.go
  • pkg/store/copr/coprocessor_test.go
  • pkg/session/tidb_test.go
  • pkg/metrics/grafana/tidb_resource_control.jsonnet
  • pkg/metrics/nextgengrafana/tidb_resource_control_with_keyspace_name.json
  • pkg/metrics/nextgengrafana/tidb_resource_control_with_keyspace_name.jsonnet
  • pkg/store/copr/coprocessor_cache.go
  • pkg/store/copr/coprocessor.go

@ti-chi-bot

ti-chi-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

@YuhaoZhang00: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

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.

@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jul 17, 2026
JmPotato and others added 3 commits July 18, 2026 17:36
…cap#68091)

close pingcap#68090

(cherry picked from commit 4ccb1ae)
Signed-off-by: JmPotato <github@ipotato.me>
…ingcap#67941)

close pingcap#68085

(cherry picked from commit ab7d93b)
Signed-off-by: JmPotato <github@ipotato.me>
ref pingcap#68085

(cherry picked from commit 10292a4)
Signed-off-by: JmPotato <github@ipotato.me>
@JmPotato
JmPotato force-pushed the codex/rc-paging-precharge-release-nextgen-202603 branch from 0d73446 to a380455 Compare July 18, 2026 09:42
ref pingcap#68085

(cherry picked from commit cae12c1)
Signed-off-by: JmPotato <github@ipotato.me>
@JmPotato
JmPotato force-pushed the codex/rc-paging-precharge-release-nextgen-202603 branch from a380455 to 6210e89 Compare July 18, 2026 10:22
@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jul 20, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-07-17 16:19:04.483536181 +0000 UTC m=+989730.519631238: ☑️ agreed by yudongusa.
  • 2026-07-20 02:50:47.738051066 +0000 UTC m=+1200433.774146132: ☑️ agreed by cfzjywxk.

@nolouch-ai nolouch-ai 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.

lgtm for metrics part

@ti-chi-bot

ti-chi-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

@nolouch-ai: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

lgtm

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.

@ti-chi-bot

ti-chi-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cfzjywxk, nolouch, nolouch-ai, yudongusa, YuhaoZhang00

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 Jul 20, 2026
@ti-chi-bot
ti-chi-bot Bot merged commit abf8c9f into pingcap:release-nextgen-202603 Jul 20, 2026
18 checks passed
@JmPotato
JmPotato deleted the codex/rc-paging-precharge-release-nextgen-202603 branch July 20, 2026 05:47
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants