Tidb报错,时间戳未赋值

【 TiDB 使用环境】测试环境
【 TiDB 版本】v7.1.0
【复现路径】执行以下sql
“SELECT * FROM " + table_name + " WHERE obj_key=? FOR UPDATE”
INSERT INTO " + table_name + " VALUES(?,?) ON DUPLICATE KEY UPDATE obj_value = ?
【遇到的问题:问题现象及影响】
性能很差,查看tidb日志有大量如下报错:
[2023/11/07 10:38:06.078 +08:00] [ERROR] [2pc.go:700] [“commit failed”] [session=6550030460196536895] [error=“try to commit with invalid txnStartTS: 18446744073709551615”]
[2023/11/07 10:38:06.078 +08:00] [WARN] [session.go:967] [“can not retry txn”] [label=general] [error=“try to commit with invalid txnStartTS: 18446744073709551615”] [IsBatchInsert=false] [IsPessimistic=false] [InRestrictedSQL=false] [tidb_retry_limit=10] [tidb_disable_txn_auto_retry=true]
[2023/11/07 10:38:06.078 +08:00] [WARN] [session.go:983] [“commit failed”] [“finished txn”=“Txn{state=invalid}”] [error=“try to commit with invalid txnStartTS: 18446744073709551615”]
[2023/11/07 10:38:06.078 +08:00] [ERROR] [terror.go:317] [“function call errored”] [error=“try to commit with invalid txnStartTS: 18446744073709551615”] [stack=“github.com/pingcap/tidb/parser/terror.Call\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/parser/terror/terror.go:317\ngithub.com/pingcap/tidb/server.(*clientConn).executePreparedStmtAndWriteResult\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/conn_stmt.go:357\ngithub.com/pingcap/tidb/server.(*clientConn).executePlanCacheStmt\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/conn_stmt.go:226\ngithub.com/pingcap/tidb/server.(*clientConn).handleStmtExecute\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/conn_stmt.go:218\ngithub.com/pingcap/tidb/server.(*clientConn).dispatch\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/conn.go:1399\ngithub.com/pingcap/tidb/server.(*clientConn).Run\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/conn.go:1153\ngithub.com/pingcap/tidb/server.(*Server).onConn\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/server/server.go:677”]

【资源配置】进入到 TiDB Dashboard -集群信息 (Cluster Info) -主机(Hosts) 截图此页面

【附件:截图/日志/监控】

其中:try to commit with invalid txnStartTS: 18446744073709551615, 时间戳的值为2^64 - 1

pd-ctl tso 18446744073709551615
system: 4199-11-24 09:22:57.663 +0800 CST
logic: 262143
看下当前tso:
begin;
select tidb_current_tso();

你的时间戳怎么这么大?我的才445472863055511553

current_tso 的值没问题:445473530876788738, 它报错的值是UINT64_MAX , 像是溢出之类的

tso时间配置的问题

pd和tidb时间是不是不同步

看看有没有锁冲突问题
TiDB 锁冲突问题处理 | PingCAP 文档中心

原因是多线程并发事务时,没有显式commit的事务默认使用乐观模式,造成startTSO没有成功被赋值

1 个赞

此话题已在最后回复的 60 天后被自动关闭。不再允许新回复。