Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
storage: fork-lift proposer-evaluated KV
Add experimental proposer-evaluated KV gated behind the environment variable `COCKROACH_PROPOSER_EVALUATED_KV`. When set to a truthy value, Raft proposals are evaluated and the resulting RocksDB `WriteBatch` submitted to Raft along with some auxiliary metadata. The result of the evaluation is only stored in the pending command on the proposer, and returned to the waiting client after the `WriteBatch` has been applied. Introduce a natural failfast path for (most) proposals returning an error. Instead of proposing, waiting for Raft, and only then receiving an error, proposals which do not lead to a state change receive their error directly when the proposal is evaluated, upstream of Raft. Only errors which still want to persist data (for instance, `*TransactionRetryError` when intents were laid down) go through the whole proposal, with the client receiving the error after the associated `Batch` commits. While proposer-evaluated KV is now ready for review, preliminary testing and benchmarking, the current implementation is incomplete and incorrect: - `Lease` acquisition is not special-cased, meaning that lease state may be clobbered freely when non-leaseholders propose a lease request based on stale data. This needs to be fixed but it also shows that we don't stress that scenario sufficiently in testing yet. - Similarly, we don't check that commands can only apply under the lease that they were proposed (which is necessary). - `CommandQueue` does not account for internal keys accessed by overlapping commands correctly (this is tracked in #10084), which in principle also lead to anomalies which should be exposed by testing and addressed. - `TestingCommandFilter` needs to be refactored to be an explicit interceptor for the pre-Raft stage of commands. Tests were fixed up enough to pass with proposer-evaluated KV as well, but it's possible that some tests don't test what they used to.
- Loading branch information