funky-eyes commented on issue #7690: URL: https://github.com/apache/incubator-seata/issues/7690#issuecomment-3413578391
> 经过mysql5.7验证,151行和152行之间也不能调用xaEnd方法,因为一阶段执行close方法会调用XA END 'xxx'和XA PREPARE ‘xxx’,然后在cleanXABranchContext方法里面把xaEnded置为false,再次执行xaEnd就会报下面的错。 所以能不能直接把166行去掉,但我不知道当时做合并事务功能加上这一行的目的是什么? > > <img alt="Image" width="1361" height="354" src="https://private-user-images.githubusercontent.com/28921885/500332673-3c0700a7-08e6-4fa3-bed1-f8b19f78ad33.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NjA2Njg4OTAsIm5iZiI6MTc2MDY2ODU5MCwicGF0aCI6Ii8yODkyMTg4NS81MDAzMzI2NzMtM2MwNzAwYTctMDhlNi00ZmEzLWJlZDEtZjhiMTlmNzhhZDMzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTEwMTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUxMDE3VDAyMzYzMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWYyNzE2YmJmNmYzMmE1MWQ1MzA1ZDc0ZTAzM2VjODFkZDgwOWFhY2JhOTc4YjVjMjRlNzdkNzQ4YmJiNDcwYTgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.qGoMvilaHMC6ycG86SUJgCpRLMrdGsSrXafKGOI88Ug"> 我认为保留166行是为了提前阻断事务,假设事务还在运行中,还未执行close,但是已经start注册了这个分支事务,不进行end是无法成功rollback的,也就无法提前阻断这个事务的进行。而cleanXABranchContext说明事务已经结束,所以close的时候清除上下文是必要的。不过我认为如果held为true时,说明这个链接被持有到二阶段,xaEnded不应该被修改为false。然后在releaseIfNecessary的时候再进行xaEnded改为false。 I think keeping line 166 is meant to preemptively block the transaction. Suppose the transaction is still running and close has not yet been called, but the branch has already been registered by start — without performing end it cannot be rolled back successfully, so you cannot preemptively stop the transaction from proceeding. The cleanXABranchContext indicates the transaction has finished, so clearing the context on close is necessary. However, I believe that if held is true (meaning this connection is held through to the second phase), xaEnded should not be set to false there; xaEnded should be set to false later in releaseIfNecessary. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
