cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
30.13k stars 3.81k forks source link

RFE: Transaction deadlines #72513

Open bobvawter opened 3 years ago

bobvawter commented 3 years ago

It would be useful to be able to set a deadline (absolute time) for a SQL transaction, as opposed to a timeout (relative time) discussed in #61102. The goal is to cover the case where a latency-sensitive application (<= 10ms) is connecting to a CRDB node which is unable to process an incoming BEGIN before the application has missed its SLA.

A syntax such as BEGIN TRANSACTION WITH DEADLINE <timestamp> would allow the CRDB node to immediately return an error if the timestamp had already passed, perhaps due to CPU overload, network congestion, etc. A session variable like SET transaction_deadline = <timestamp> could also be used, which would apply to all subsequent transactions in the session.

jordanlewis commented 2 years ago

@rafiss would the proposed solution in #61102 be able to help with this issue as well, if a user specified the timeout with deadline - now()?

rafiss commented 2 years ago

Yes, seems like it would help, but it wouldn't be able to be configured per-transaction since the timeout in https://github.com/cockroachdb/cockroach/issues/61102 is being proposed as a session setting.