github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/docs/RFCS/20191014_savepoints/leafbase.puml (about) 1 @startuml 2 skinparam BoxPadding 10 3 4 box "On the gateway node" 5 participant SQL 6 participant RootTxn 7 end box 8 box "On another node" 9 participant dSQLServer 10 participant LeafTxn 11 end box 12 participant cluster 13 14 create RootTxn 15 SQL -> RootTxn : client.NewTxn(RootTxn) 16 ... 17 note left of SQL 18 forking RootTxn 19 into LeafTxn meta 20 end note 21 SQL -> RootTxn : txn.GetTxnCoordMeta() 22 RootTxn --> SQL : TxnCoordMeta 23 SQL -> SQL : leafmeta.StripRootToLeaf() 24 SQL -> dSQLServer : SetupFlow(proc spec, leafmeta) 25 note over dSQLServer,LeafTxn: (dSQL proc starts exec) 26 note left of SQL: actually instantiating LeafTxn 27 create LeafTxn 28 dSQLServer -> LeafTxn : client.NewTxnWithCoordMeta() 29 ... 30 note left of SQL 31 LeafTxn issuing reads 32 on behalf of RootTxn 33 end note 34 dSQLServer -> LeafTxn : txn.Run(client.Batch) 35 LeafTxn -> cluster : txn.sender.Send(roachpb.BatchRequest) 36 ... 37 cluster --> LeafTxn : BatchResponse 38 LeafTxn --> dSQLServer : Batch modified in-place 39 dSQLServer --> SQL : some results 40 ... 41 note over dSQLServer,LeafTxn: (dSQL proc finishes exec) 42 note left of SQL 43 updates to LeafTxn 44 repatriated into RootTxn 45 end note 46 dSQLServer -> LeafTxn : GetTxnCoordMeta() 47 LeafTxn --> dSQLServer : TxnCoordMeta 48 dSQLServer -> dSQLServer : leafmeta.StripLeafToRoot() 49 dSQLServer --> SQL : final results + leafmeta 50 SQL -> RootTxn : txn.AugmentTxnCoordMeta(leafmeta) 51 ... 52 SQL -> RootTxn : Commit/Rollback/CleanupOnError 53 @enduml