From 108d20a439f29b4f9d8c8b5e4ee2eb60fedf86d2 Mon Sep 17 00:00:00 2001 From: you06 Date: Wed, 29 Oct 2025 22:04:34 +0900 Subject: [PATCH] txn: remove `IsTempIndexKey` which bypass the checks for temp index keys (#1778) Signed-off-by: you06 --- tikv/kv.go | 7 ------- txnkv/transaction/prewrite.go | 7 ++----- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/tikv/kv.go b/tikv/kv.go index f3e3b28a..257a036d 100644 --- a/tikv/kv.go +++ b/tikv/kv.go @@ -1091,10 +1091,3 @@ type SchemaVer = transaction.SchemaVer // MaxTxnTimeUse is the max time a Txn may use (in ms) from its begin to commit. // We use it to abort the transaction to guarantee GC worker will not influence it. const MaxTxnTimeUse = transaction.MaxTxnTimeUse - -// SetIsTempIndexKey inject the function to check whether a key is a temporary index key. -// Call this function before using this package. -// If not set, all keys will be treated as non-temporary index keys. -func SetIsTempIndexKey(fn func([]byte) bool) { - transaction.IsTempIndexKey = fn -} diff --git a/txnkv/transaction/prewrite.go b/txnkv/transaction/prewrite.go index 44c19e3f..23f77bb3 100644 --- a/txnkv/transaction/prewrite.go +++ b/txnkv/transaction/prewrite.go @@ -102,9 +102,8 @@ func (c *twoPhaseCommitter) buildPrewriteRequest(batch batchMutations, txnSize u } if m.IsPessimisticLock(i) { pessimisticActions[i] = kvrpcpb.PrewriteRequest_DO_PESSIMISTIC_CHECK - } else if m.NeedConstraintCheckInPrewrite(i) || - (config.NextGen && IsTempIndexKey != nil && !IsTempIndexKey(m.GetKey(i))) { - // For next-gen builds, we need to perform constraint checks on all non-temporary index keys. + } else if m.NeedConstraintCheckInPrewrite(i) || config.NextGen { + // For next-gen builds, we need to perform constraint checks on all non-locked keys. // This is to prevent scenarios where a later lock's start_ts is smaller than the previous write's commit_ts, // which can be problematic for CDC and could potentially break correctness. // see https://github.com/tikv/tikv/issues/11187. @@ -630,5 +629,3 @@ func (handler *prewrite1BatchReqHandler) handleSingleBatchSucceed(reqBegin time. } return nil } - -var IsTempIndexKey func([]byte) bool