You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 18, 2023. It is now read-only.
300: Hrana batches r=honzasp a=honzasp
The whole "edge" is (only) about reducing latency, so sqld clients should strive to minimize the number of network roundtrips. This means that users should prefer batched transactions to interactive transaction; these should take just a single roundtrip.
Unfortunately, up until now it was impossible to safely implement batched transactions in Hrana with just a single roundtrip. To execute a batch of statements _S1, ..., Sn_, we need to do the following:
- Execute a `BEGIN` statement
- If the `BEGIN` statement was successful, execute _S1_
- If `BEGIN` and _S1_ were successful, execute _S2_
- ...
- If `BEGIN` and _S1, ..., Sn-1_ were successful, execute _Sn_
- If `BEGIN` and _S1, ..., Sn_ were successful, execute `COMMIT`, otherwise execute a `ROLLBACK`
In other words, we need to execute statements conditionally, based on results of previous statements. The only way to do this in Hrana is to wait for the responses, so we need _n+2_ roundtrips instead of just one!
---
This PR changes that by introducing the concept of "batch" to the Hrana protocol. A batch is a sequence of steps, and each step is an SQL statement with optional condition. The condition can refer to success or failure of previous steps. This mechanism will allow clients to implement batched transactions using a single roundtrip.
This PR replaces #294 and #295 after discussion with `@MarinPostma.`
Co-authored-by: Jan Špaček <[email protected]>
0 commit comments