github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/docs/tech-notes/txn_coord_sender/txncoordsender.puml (about) 1 @startuml 2 box "On any node using txns" 3 participant "SQL executor\nor distsql server" as SQL 4 participant "RootTxn\nor LeafTxn" as Txn 5 participant TxnCoordSender 6 end box 7 participant cluster 8 9 note over SQL: SQL transaction starts 10 create Txn 11 SQL -> Txn : client.NewTxn(Txn) 12 create TxnCoordSender 13 Txn -> TxnCoordSender : db.factory.TransactionalSender() 14 TxnCoordSender -> TxnCoordSender : initialize txn object 15 ... 16 note over SQL: during query execution 17 SQL -> Txn : txn.Run(client.Batch) 18 Txn -> Txn : translate Batch into BatchRequest 19 Txn -> TxnCoordSender: sender.Send(BatchRequest) 20 TxnCoordSender -> TxnCoordSender: populate txn object into batch 21 TxnCoordSender -> cluster : distsender.Send(BatchRequest) 22 ... 23 cluster --> TxnCoordSender : BatchResponse w/ txn object update 24 TxnCoordSender -> TxnCoordSender: txn.Update(resp.Txn) 25 TxnCoordSender --> Txn : BatchResponse 26 Txn --> SQL : Batch modified in-place 27 ... 28 note over SQL 29 when SQL txn completes 30 (only on the SQL gateway / RootTxn) 31 end note 32 SQL -> Txn : Commit/Rollback/CleanupOnError 33 Txn -> Txn : construct BatchRequest with EndTxnRequest 34 Txn -> TxnCoordSender : sender.Send(BatchRequest) 35 TxnCoordSender --> cluster : clean up (not always) 36 TxnCoordSender -> TxnCoordSender : finalize txn 37 @enduml