Skip to content

Conversation

@pingyu
Copy link
Collaborator

@pingyu pingyu commented Jan 19, 2026

Cherry pick:

Changes

  • Change to use kv_resolve_lock interface for resolving locks
    • The kv_cleanup is deprecated since 4.0 (see kvrpcpb.proto). As client-rust announce to support TiKV >= v5.0.0 (see README.md), it should be safe to replace.
  • Support handling locks of file based transactions (submitting is not supported).
  • Resolving pessimistic & async commit locks is not implemented yet.

Review comments from LLM (with prompt that compare Go implementation as source of correctness):

(The backoff will be added in another PR. See #511).

  - Main semantic change vs master: resolve_locks now checks txn status for all encountered locks via CheckTxnStatus, and only treats locks as “live” when TiKV reports Locked; if TiKV reports Committed/RolledBack,
    it immediately sends ResolveLock (so committed locks get resolved even when TTL hasn’t expired). This matches the client-go flow in resolveLocks → getTxnStatusFromLock → resolveLock (ignoring pessimistic/async-
    commit paths as requested). See src/transaction/lock.rs:51.
  - The new caller_start_ts plumbing (added timestamp parameter into the resolve-lock plan) is consistent with client-go’s ResolveLocksOptions.CallerStartTS. See src/request/plan_builder.rs:74 and src/request/
    plan.rs:599.
  - TxnNotFound handling now mirrors client-go’s txnNotFoundErr loop: retry until the lock expires, then set rollback_if_not_exist and re-check; otherwise backoff and retry. See src/transaction/lock.rs:493 and src/
    transaction/lock.rs:392.

  Potential gaps to double-check (not about pessimistic/async-commit):

  - Client-go handles primaryMismatch specially; Rust has // TODO: handle primary mismatch error. and currently returns Error::KeyError for that case. This can cause “stuck” resolution if TiKV returns a primary-
    mismatch KeyError. See src/transaction/lock.rs:392.
  - resolve_lock_with_retry still has “FIXME: Add backoff” and retries region errors in a tight loop; client-go backs off on region misses. See src/transaction/lock.rs:144.
  - cleanup_locks now calls check_txn_status which can return Error::TxnNotFound, but cleanup_locks doesn’t retry/backoff that case (unlike the read-path’s get_txn_status_from_lock). See src/transaction/lock.rs:262
    and src/transaction/lock.rs:392.

Signed-off-by: Ping Yu <yuping@pingcap.com>
Signed-off-by: Ping Yu <yuping@pingcap.com>
Signed-off-by: Ping Yu <yuping@pingcap.com>
Signed-off-by: Ping Yu <yuping@pingcap.com>
Signed-off-by: Ping Yu <yuping@pingcap.com>
@ti-chi-bot ti-chi-bot bot added dco-signoff: yes Indicates the PR's author has signed the dco. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 19, 2026
Signed-off-by: Ping Yu <yuping@pingcap.com>
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jan 19, 2026
@ti-chi-bot ti-chi-bot bot added the lgtm label Jan 20, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Jan 20, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: coocood, iosmanthus

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 removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jan 20, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Jan 20, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-01-19 12:09:01.177966555 +0000 UTC m=+409368.791923401: ☑️ agreed by iosmanthus.
  • 2026-01-20 02:09:01.215999259 +0000 UTC m=+459768.829956105: ☑️ agreed by coocood.

@ti-chi-bot ti-chi-bot bot merged commit 7d80f59 into tikv:master Jan 20, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved dco-signoff: yes Indicates the PR's author has signed the dco. lgtm size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants