Repository navigation
Conversation
Use the number of scanned holders when advancing pages. A live shared wrapper can occupy a whole page, so move past its physical key to reach later data locks. GC still resolves every holder and rescans the last key inclusively. Signed-off-by: Ziqian Qin <eke@fastmail.com>
Opt in pessimistic shared reads to selecting a fixed shared primary and sending an explicit upgrade request. Keep ordinary 2PC and normal locking for the remainder of the transaction, even when all S holders subsequently upgrade or the session option changes. Legacy shared-secondary callers retain their previous behavior. Signed-off-by: Ziqian Qin <eke@fastmail.com>
Remember the deadlock before returning it to SQL and skip statement retry. This also applies when the victim was waiting for a new exclusive key. Preserve the existing deadlock diagnostic and leave rollback available. Signed-off-by: Ziqian Qin <eke@fastmail.com>
Check the authoritative GC state after all prewrites have been acknowledged and before issuing the first primary commit. A fresh local visibility cache may still predate collection of a lost shared lock’s conflict record. Check both transaction and data safe points, including the old PD/etcd representation, and propagate lookup failures before commit. Signed-off-by: Ziqian Qin <eke@fastmail.com>
An upgrader does not need to resolve its own S or recently touched peers. Still return NOWAIT or an expired timeout in that path, instead of reissuing requests beyond the statement budget. Signed-off-by: Ziqian Qin <eke@fastmail.com>
Use the transaction lifetime capability on every prewrite batch and retry. Existing shared-secondary clients leave the bit unset and keep strict missing-lock failure semantics. Signed-off-by: Ziqian Qin <eke@fastmail.com>
Discard successful RC and upgrade replies and drive actual RPC retries against Classic TiKV. Separately remove a shared holder, commit an intervening lock-only X, and verify rejection on both the prewrite and explicit-upgrade paths. Signed-off-by: Ziqian Qin <eke@fastmail.com>
A start timestamp equal to the transaction safe point remains readable when the data safe point is older. Data GC can collect the primary’s protected rollback at equality, so preserve the stricter check on the data safe point. Signed-off-by: Ziqian Qin <eke@fastmail.com>
Shared lock cases only own the memcomparable keys under their test prefix. The whole suite should leave unrelated SQL rows and database metadata untouched when running against an isolated Classic cluster. Signed-off-by: Ziqian Qin <eke@fastmail.com>
A shared lock conflict describes several owners in one Lock CF value. Feeding the envelope to ResolveLocks fails immediately and aborts a normal pipelined writer. Expand the members before applying optimism checks, logging and resolution. Exercise real 2PC, one-phase, async and flush requests while two independent shared readers release in order. Signed-off-by: Ziqian Qin <eke@fastmail.com>
|
Skipping CI for Draft Pull Request. |
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Note
Wave 2 Draft PR — depends on pingcap/kvproto#1594 and TiKV shared-lock support (
tikv/tikv#20423..#20425) landing inpingcap/tikv:nightlyforintegration-tikvCI.go.mod,go.sum, andintegration_tests/go.modto the mergedpingcap/kvproto#1594commit SHA.Problem
Tracking: pingcap/tidb#73623, tikv/tikv#20422
Supporting native
SELECT ... FOR SHAREin Classic TiDB requires the transaction coordinator to manage shared primary locks, explicit S→X upgrades, deadlock-victim aborts, commit-time GC safety checks for missing-lock recovery, data-lock pagination past dense shared-lock wrappers, and pipelined write compatibility.Changes
is_shared_lock_upgradeon upgrades, abort shared-read transactions chosen as deadlock victims, and charge elapsed retry time against the caller'sNOWAIT/ lock-wait budget when skipping live holders.allow_shared_lock_amendon prewrite requests for shared-read transactions. After all prewrites succeed and before committing the primary, query the authoritative transaction and data GC safe points from PD/storage and reject commit ifstartTS < txnSafePointorstartTS <= dataSafePoint(inclusive on the data boundary because TiKV data GC can reclaim a protected rollback written exactly atstartTS; paired withpingcap/tidb#73624). Legacy callers leave the flag unset.ResolveDataLocksForRange): AddResolveDataLocksForRangefor checkpoint repair callers (such as BR) to skip lock-only entries (Op_SharedLock,Op_Lock,Op_PessimisticLock) and advance past full pages of shared holders, while keepingResolveLocksForRangeunchanged so GC continues resolving every lock.Planned for backport to
tidb-8.5once merged.Validation
go test -tags=intest -count=1 ./tikv ./txnkv/transactiongo test -race -tags=intest -count=1 ./txnkv/transaction -run 'Test.*Shared'