Skip to content

sysvar: copr_resolve_lock_lite#2

Open
ekexium wants to merge 4 commits into
0xPoe:cherry-pick-64501-to-release-nextgen-20251011from
ekexium:release-nextgen-20251011-forbid-resolve-region
Open

sysvar: copr_resolve_lock_lite#2
ekexium wants to merge 4 commits into
0xPoe:cherry-pick-64501-to-release-nextgen-20251011from
ekexium:release-nextgen-20251011-forbid-resolve-region

Conversation

@ekexium
Copy link
Copy Markdown

@ekexium ekexium commented Apr 19, 2026

What problem does this PR solve?

Issue Number: close #xxx

Problem Summary:

What changed and how does it work?

SessionVars.CoprResolveLockLite
→ DistSQLContext.CoprResolveLockLite
→ kv.Request.CoprResolveLockLite
→ NewClientHelper(..., resolveLite)
→ ClientHelper.resolveLite
→ ResolveLocksWithOpts(opts.Lite = true)

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

Signed-off-by: ekexium <eke@fastmail.com>
Copilot AI review requested due to automatic review settings April 19, 2026 03:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new TiDB system variable to control whether coprocessor requests use “resolve lock lite”, and wires that setting from session vars through DistSQL request construction down to the coprocessor worker KV client helper.

Changes:

  • Add new sysvar tidb_copr_resolve_lock_lite (global + session) and corresponding SessionVars field.
  • Plumb the flag through DistSQLContextkv.Request → coprocessor worker (txnsnapshot.NewClientHelper(..., CoprResolveLockLite)).
  • Update DistSQL context detach unit test to include the new field.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/store/copr/coprocessor.go Pass request flag into txnsnapshot.NewClientHelper so copr lock resolution behavior can be toggled.
pkg/sessionctx/variable/sysvar.go Register new sysvar and apply it to SessionVars.
pkg/sessionctx/variable/session.go Add SessionVars.CoprResolveLockLite field.
pkg/sessionctx/vardef/tidb_vars.go Define sysvar name and default value constant.
pkg/session/session.go Include the session flag in DistSQLContext construction.
pkg/kv/kv.go Add CoprResolveLockLite to kv.Request for downstream plumbing.
pkg/distsql/request_builder.go Copy DistSQLContext.CoprResolveLockLite into kv.Request.
pkg/distsql/context/context.go Add flag to DistSQLContext struct (inherits into Detach() via struct copy).
pkg/distsql/context/context_test.go Extend detach test coverage for the new field.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}},
{Scope: vardef.ScopeGlobal | vardef.ScopeSession, Name: vardef.TiDBCoprResolveLockLite, Value: BoolToOnOff(vardef.DefTiDBCoprResolveLockLite), Type: vardef.TypeBool, SetSession: func(s *SessionVars, val string) error {
s.CoprResolveLockLite = TiDBOptOn(val)
return nil
Comment on lines 373 to +376
builder.Request.RunawayChecker = dctx.RunawayChecker
builder.Request.TiKVClientReadTimeout = dctx.TiKVClientReadTimeout
builder.Request.MaxExecutionTime = dctx.MaxExecutionTime
builder.Request.CoprResolveLockLite = dctx.CoprResolveLockLite
@ekexium ekexium force-pushed the release-nextgen-20251011-forbid-resolve-region branch from f7665ab to bc40d9d Compare April 19, 2026 04:19
Add a session variable to control whether coprocessor resolves locks
synchronously. When ON (default), lock resolution blocks until complete
before retrying. When OFF, locks are resolved asynchronously in goroutines.

Works with the new SyncResolve option in client-go's ResolveLocksOptions,
which forces synchronous resolution while preserving ForRead semantics
(read-through for canIgnore/canAccess classification).
@ekexium ekexium force-pushed the release-nextgen-20251011-forbid-resolve-region branch from bc40d9d to cfdaa05 Compare April 19, 2026 04:25
ti-chi-bot and others added 2 commits April 19, 2026 12:31
Signed-off-by: ekexium <eke@fastmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants