使用 spring cloud 集群 + seata 集群 ,seata 版本1.4.2 ,db模式,报错如下
Error updating database. Cause: java.sql.SQLException: io.seata.core.exception.RmTransactionException: Response[ TransactionException[Could not found global transaction xid = xxxxxx:8091:2010657011, may be has finished.] ]
排除接口超时问题
9条答案
按热度按时间bq8i3lrv1#
Check whether the maximum transaction execution time (1 minute by default) is exceeded.
doinxwow2#
1.application.properties
seata.client.tm.default-global-transaction-timeout=300000
2.The execution time of this api is 7 seconds
Check whether the maximum transaction execution time (1 minute by default) is exceeded.
rsl1atfo3#
通过xid去tc侧查看事务决议的时间是什么时候
Go to the tc side through xid to check when the transaction resolution is
r6l8ljro4#
通过xid去tc侧查看事务决议的时间是什么时候 Go to the tc side through xid to check when the transaction resolution is
@before("transactionPointcut()")
public void before(JoinPoint joinPoint) throws TransactionException {
String treadName = Thread.currentThread().getName();
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
// 此处可用redis或者定时任务来获取一个key判断是否需要关闭分布式事务
// 模拟动态关闭分布式事务
String fullMethodName = signature.getDeclaringTypeName() + "." + method.getName();
String methodName = method.getName();
if (isNeedDistributedTransaction(methodName,fullMethodName)) {
log.debug("############# 分布式事务. xid:{};fullMethodName:{}", RootContext.getXID(), fullMethodName);
if (StringUtils.isBlank(RootContext.getXID())) {
GlobalTransaction tx = GlobalTransactionContext.getCurrentOrCreate();
log.debug("############# GlobalTransactionContext:{}", GlobalTransactionContext.getCurrentOrCreate());
tx.begin(180000, "GlobalTransaction:" + fullMethodName);
log.debug("############# 开启分布式事务. xid:{};fullMethodName:{}", RootContext.getXID(), fullMethodName);
CurrentUserInfo currentUserInfo = CurrentUserInfoHolder.get();
CurrentUserInfoHolder.get().setIsBeginSeataTransaction(true);
} else {
log.debug("############# 绑定分布式事务. xid:{};fullMethodName:{}", RootContext.getXID(), fullMethodName);
CurrentUserInfo currentUserInfo = CurrentUserInfoHolder.get();
Boolean isBeginSeataTransaction = CurrentUserInfoHolder.get().getIsBeginSeataTransaction();
RootContext.bind(RootContext.getXID());
}
tx.begin(180000, "GlobalTransaction:" + fullMethodName);
我们是通过切面管理事务,在并发情况下,这里的name都是一样的,这里会有影响吗
GlobalTransaction.begin()
fullMethodName是全路径的接口名:com.xxx.xxx
yquaqz185#
xid 不同就不会有影响,你应该根据tc的决议时间的日志来辅助判断你的代码是否有bug
It will not be affected if the xid is different. You should help determine whether there is a bug in your code according to the log of the resolution time of the tc.
fykwrbwg6#
xid 不同就不会有影响,你应该根据tc的决议时间的日志来辅助判断你的代码是否有bug It will not be affected if the xid is different. You should help determine whether there is a bug in your code according to the log of the resolution time of the tc.
[24-08-14.01:26:01.836 [XNIO-1 task-1 ] WARN XidResource - xid in change during RPC from null to xxxxxxxxxxxxx:8091:27574317618311697
[24-08-14.01:26:01.836 [XNIO-1 task-1 ] WARN XidResource - bind [xxxxxxxxx:8091:27574317618311697] back to RootContext
[24-08-14.01:26:03.855 [XNIO-1 task-1 ] WARN XidResource - xid in change during RPC from null to xxxxxxxxxxxxx:8091:27574317618311697
[24-08-14.01:26:03.855 [XNIO-1 task-1 ] WARN XidResource - bind [xxxxxxxxx:8091:27574317618311697] back to RootContext
[24-08-14.01:26:05.061 [XNIO-1 task-1 ] ERROR AbstractDMLBaseExecutor - execute executeAutoCommitTrue error:io.seata.core.exception.RmTransactionException: Response[ TransactionException[Could not found global transaction xid = xxxxxxxxxxxxx:8091:27574317618311697, may be has finished.] ]
java.sql.SQLException: io.seata.core.exception.RmTransactionException: Response[ TransactionException[Could not found global transaction xid = xxxxxxxxxxxxx:8091:27574317618311697, may be has finished.] ]
这个是应用服务的seata-client日志,为啥这里会from null ,我看正常的都会有,这个是分支的xid没有注册上嘛
7kqas0il7#
tc的决议时间的日志
tc的决议时间的日志是看client端还是server端
68bkxrlz8#
Caused by: io.seata.core.exception.RmTransactionException: Response[ TransactionException[Could not found global transaction xid = xxxxxxxxxxxxxxx:8091:27574317618311697, may be has finished.] ]
at io.seata.rm.AbstractResourceManager.branchRegister(AbstractResourceManager.java:69)
at io.seata.rm.DefaultResourceManager.branchRegister(DefaultResourceManager.java:96)
at io.seata.rm.datasource.ConnectionProxy.register(ConnectionProxy.java:272)
at io.seata.rm.datasource.ConnectionProxy.processGlobalTransactionCommit(ConnectionProxy.java:250)
... 219 common frames omitted
p5fdfcr19#
[verHandlerThread_1_28_500]�[0;39m �[36mi.s.c.e.AbstractExceptionHandler �[0;39m �[2m:�[0;39m Catch TransactionException while do RPC, request: xid=xxxxxxxxxxxxx:8091:27574317618311697,branchType=AT,resourceId=jdbc:mysql://xxxxxxxxxx:3306/cloud_shop_service,lockKey=shop_shop_product:354259
==>
io.seata.core.exception.GlobalTransactionException: Could not found global transaction xid = xxxxxxxxxxxx:8091:27574317618311697, may be has finished.
at io.seata.server.coordinator.AbstractCore.assertGlobalSessionNotNull(AbstractCore.java:126) ~[seata-server-1.4.2.jar:na]
at io.seata.server.coordinator.AbstractCore.branchRegister(AbstractCore.java:76) ~[seata-server-1.4.2.jar:na]
at io.seata.server.coordinator.DefaultCore.branchRegister(DefaultCore.java:100) ~[seata-server-1.4.2.jar:na]
at io.seata.server.coordinator.DefaultCoordinator.doBranchRegister(DefaultCoordinator.java:199) [seata-server-1.4.2.jar:na]
at io.seata.server.AbstractTCInboundHandler$4.execute(AbstractTCInboundHandler.java:184) ~[seata-server-1.4.2.jar:na]
at io.seata.server.AbstractTCInboundHandler$4.execute(AbstractTCInboundHandler.java:179) ~[seata-server-1.4.2.jar:na]
at io.seata.core.exception.AbstractExceptionHandler.exceptionHandleTemplate(AbstractExceptionHandler.java:124) ~[seata-core-1.4.2.jar:na]
at io.seata.server.AbstractTCInboundHandler.handle(AbstractTCInboundHandler.java:179) [seata-server-1.4.2.jar:na]
at io.seata.core.protocol.transaction.BranchRegisterRequest.handle(BranchRegisterRequest.java:136) [seata-core-1.4.2.jar:na]
at io.seata.server.coordinator.DefaultCoordinator.onRequest(DefaultCoordinator.java:473) [seata-server-1.4.2.jar:na]
at io.seata.core.rpc.processor.server.ServerOnRequestProcessor.onRequestMessage(ServerOnRequestProcessor.java:116) [seata-core-1.4.2.jar:na]
at io.seata.core.rpc.processor.server.ServerOnRequestProcessor.process(ServerOnRequestProcessor.java:77) [seata-core-1.4.2.jar:na]
at io.seata.core.rpc.netty.AbstractNettyRemoting.lambda$processMessage$2(AbstractNettyRemoting.java:279) [seata-core-1.4.2.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_291]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_291]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-all-4.1.30.Final.jar:4.1.30.Final]
at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_291]
<==