Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
28185: client, kv: move logic out of Txn, rewrite some of the TxnCoordSender r=andreimatei a=andreimatei This patch moves most of the logic from the client.Txn into the kv.TxnCoordSender and reorganizes much of the TxnCoordSender in the process. The split between the client.Txn and the TxnCoordSender caused a lot of grief historically. The main problem is that both the Txn and the TCS each have their own copy of the roachpb.Transaction proto. They both use their copy for different things. We attempt to keep the two protos in sync, but we can't ensure that as there's no common locking between the two layers. This patch keeps the client.Txn as a mostly stateless shim, allowing one to mock everything underneath. This is nice, as previously "mocking KV" was a less clear proposition - does one mock all the logic in the Txn or just the TCS? Now the TCS has all the logic and all the locking necessary for serializing accesses to the "transaction state" - notably the proto. The Txn and TCS communicate through a (now expanded) client.TxnSender interface. Within the TCS, the biggest change is that everything that has to do with the heartbeat loop has been moved to a new interceptor. The metrics generation has also been extracted into a new interceptor. One behavior change introduced by this patch is that heartbeat loops are no longer started for (what the TCS hopes will be) 1PC txns. The motivation was concern over the price of spawning a (shortlived) heartbeat goroutine per txn in the 1PC-heavy "kv" workload. Another one is that the TxnCoordSender doesn't inherit the old Txn logic for swallowing errors on rollbacks. Instead, we're relying on a recent server change to not return errors on rollbacks when the txn record is missing - which was the reason for said swallowing. Fixes cockroachdb#28256 Release note: none Co-authored-by: Andrei Matei <[email protected]>
- Loading branch information