seata RM基本分析

seata RM端 AT(自动事务)模式相关主要类可以分为以下几种

  • JDBC Proxy, 封装jdbc datasource、connection、preparedstatement及statement,其中DataSourceProxy提供是否proxy的连接,plaintConnection指实际数据库连接,直接使用plain connection模式主要是用于提交undolog及无法识别(无需处理)的SQL处理
  • undo log信息,包括before image、after image,都在通过connectionProxy的commit 动作提交,以保障在同一DataSource下undo log与业务数据库操作一起被commit
  • SQL的执行通过ExecuteTemplate及相关Excutor类来实现,ExecuteTemplate根据类型(insert/update/delete/select_for_update)调用不同Executor,具体看execute函数
  • undo log操作及undo操作都是异步执行,由TC发消息给RM,RM负责执行,rollback 执行关键函数public class MySQLUndoLogManager extends AbstractUndoLogManager 的undo函数
  • Tablemeta 信息会被缓存并且每一分钟定时刷新

接收TC信息的调用stack如下

Daemon Thread [rpcDispatch_RMROLE_1_8] (Suspended (breakpoint at line 126 in MySQLUndoLogManager))	
	MySQLUndoLogManager.undo(DataSourceProxy, String, long) line: 126	
	DataSourceManager.branchRollback(BranchType, String, long, String, String) line: 179	
	RMHandlerAT(AbstractRMHandler).doBranchRollback(BranchRollbackRequest, BranchRollbackResponse) line: 124	
	AbstractRMHandler$2.execute(BranchRollbackRequest, BranchRollbackResponse) line: 68	
	AbstractRMHandler$2.execute(AbstractTransactionRequest, AbstractTransactionResponse) line: 1	
	RMHandlerAT(AbstractExceptionHandler).exceptionHandleTemplate(AbstractExceptionHandler$Callback, AbstractTransactionRequest, AbstractTransactionResponse) line: 117	
	RMHandlerAT(AbstractRMHandler).handle(BranchRollbackRequest) line: 64	
	DefaultRMHandler.handle(BranchRollbackRequest) line: 64	
	BranchRollbackRequest.handle(RpcContext) line: 35	
	DefaultRMHandler(AbstractRMHandler).onRequest(AbstractMessage, RpcContext) line: 149	
	RmMessageListener.handleBranchRollback(RpcMessage, String, BranchRollbackRequest, ClientMessageSender) line: 81	
	RmMessageListener.onMessage(RpcMessage, String, ClientMessageSender) line: 71	
	RmRpcClient(AbstractRpcRemotingClient).dispatch(RpcMessage, ChannelHandlerContext) line: 166	
	AbstractRpcRemoting$3.run() line: 371	
	ThreadPoolExecutor.runWorker(ThreadPoolExecutor$Worker) line: not available	
	ThreadPoolExecutor$Worker.run() line: not available	
	FastThreadLocalRunnable.run() line: 30	
	FastThreadLocalThread(Thread).run() line: not available	

seata RM基本分析_第1张图片

你可能感兴趣的:(Seata,seata,rm)