From 3ec86a77f7df50be311c5fdaecc9bd6844af77ca Mon Sep 17 00:00:00 2001 From: Bin Zhang Date: Sat, 7 Dec 2024 08:26:44 -0800 Subject: [PATCH] dont check startts if it is preset --- pkg/sessiontxn/isolation/base.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/sessiontxn/isolation/base.go b/pkg/sessiontxn/isolation/base.go index 5300f9623b4ce..feee341fd4595 100644 --- a/pkg/sessiontxn/isolation/base.go +++ b/pkg/sessiontxn/isolation/base.go @@ -270,6 +270,10 @@ func (p *baseTxnContextProvider) getTxnStartTS() (uint64, error) { return txn.StartTS(), nil } +func (p *baseTxnContextProvider) usePresetStartTS() bool { + return p.constStartTS != 0 || p.sctx.GetSessionVars().SnapshotTS != 0 +} + // ActivateTxn activates the transaction and set the relevant context variables. func (p *baseTxnContextProvider) ActivateTxn() (kv.Transaction, error) { if p.txn != nil { @@ -307,7 +311,7 @@ func (p *baseTxnContextProvider) ActivateTxn() (kv.Transaction, error) { } // verify start_ts is later than any previous commit_ts in the session - if sessVars.LastCommitTS > 0 && sessVars.LastCommitTS > sessVars.TxnCtx.StartTS { + if !p.usePresetStartTS() && sessVars.LastCommitTS > 0 && sessVars.LastCommitTS > sessVars.TxnCtx.StartTS { logutil.BgLogger().Panic("check session lastCommitTS failed", zap.Uint64("lastCommitTS", sessVars.LastCommitTS), zap.Uint64("startTS", sessVars.TxnCtx.StartTS),