Skip to content

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

Open
JmPotato wants to merge 3 commits into
pingcap:release-nextgen-202603from
JmPotato:codex/rc-paging-precharge-release-nextgen-202603
Open

*: backport RC paging pre-charge to release-nextgen-202603#69830
JmPotato wants to merge 3 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.

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.
  • 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

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, and the Resource Control Grafana dashboard adds paging pre-charge observability.

Summary by CodeRabbit

  • New Features
    • Added byte-budget paging for coprocessor requests, allowing pages to be limited by read size.
    • Added the tidb_paging_size_bytes session variable; 0 disables byte-budget paging.
    • Byte-budget paging is automatically applied only where supported and for eligible resource-controlled workloads.
  • Monitoring
    • Added Grafana panels for paging pre-charge coverage, paging byte rates, and prediction accuracy.
  • Bug Fixes
    • Improved paging cache handling and compatibility across coprocessor 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

📝 Walkthrough

Walkthrough

Adds tidb_paging_size_bytes and propagates byte-budget paging through session, DistSQL, KV, and TiKV coprocessor execution. Coprocessor workers use EMA-based read-byte prediction, cache handling is updated, dashboards expose paging metrics, and related dependencies and tests are refreshed.

Changes

Paging pre-charge and repository refresh

Layer / File(s) Summary
Go module and repository refresh
go.mod, DEPS.bzl
Updates pinned versions and integrity metadata for kvproto, client-go, and PD client repositories.
Paging configuration and session propagation
pkg/sessionctx/..., pkg/session/..., pkg/distsql/..., pkg/kv/kv.go, pkg/executor/distsql.go, tests/integrationtest/...
Adds the paging byte-budget system variable, gates it by resource-group state, and propagates it into DistSQL and KV requests.
Coprocessor byte-budget execution and EMA
pkg/store/copr/...
Adds EMA prediction and observation, forwards paging byte budgets to TiKV, updates task, cache, batching, and response handling, and adds coverage for the new behavior.
Paging pre-charge dashboards
pkg/metrics/grafana/*, pkg/metrics/nextgengrafana/*
Adds dashboard rows and panels for pre-charge coverage, paging byte rates, and prediction residual quantiles.

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

Sequence Diagram(s)

sequenceDiagram
  participant Session
  participant DistSQL
  participant Coprocessor
  participant TiKV
  Session->>DistSQL: propagate PagingSizeBytes
  DistSQL->>Coprocessor: build paging request
  Coprocessor->>TiKV: send predicted read bytes
  TiKV-->>Coprocessor: return page and read-byte details
  Coprocessor->>Coprocessor: update EMA
Loading

Possibly related PRs

Suggested reviewers: ti-chi-bot, wfxr

Poem

I’m a rabbit with bytes in my paws,
Paging through coprocessor halls.
EMA predicts each hop just right,
Dashboards bloom in pre-charge light.
Pins refresh, tests happily run—
A burrow-sized feature for everyone!

🚥 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 is concise and correctly summarizes the backport of RC paging pre-charge to the release-nextgen-202603 branch.
Description check ✅ Passed The description follows the template, includes the issue reference, change summary, checklist, and release note, with only a sparse problem summary.
✨ 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

…cap#68091)

close pingcap#68090

(cherry picked from commit 4ccb1ae)
Signed-off-by: JmPotato <github@ipotato.me>
@JmPotato JmPotato force-pushed the codex/rc-paging-precharge-release-nextgen-202603 branch from 46cbdfe to 85a15b9 Compare July 16, 2026 11:53
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.56627% with 7 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release-nextgen-202603@02d7646). Learn more about missing BASE report.

Additional details and impacted files
@@                     Coverage Diff                     @@
##             release-nextgen-202603     #69830   +/-   ##
===========================================================
  Coverage                          ?   76.1839%           
===========================================================
  Files                             ?       1937           
  Lines                             ?     541067           
  Branches                          ?          0           
===========================================================
  Hits                              ?     412206           
  Misses                            ?     128861           
  Partials                          ?          0           
Flag Coverage Δ
unit 76.1839% <91.5662%> (?)

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

YuhaoZhang00 and others added 2 commits July 16, 2026 21:31
…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 85a15b9 to 0d73446 Compare July 16, 2026 13:32
@ti-chi-bot

ti-chi-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign cfzjywxk, terry1purcell, xuhuaiyu for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found 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

@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

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

Labels

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.

2 participants