tursodatabase / libsql

libSQL is a fork of SQLite that is both Open Source, and Open Contributions.
https://turso.tech/libsql
MIT License
8.87k stars 235 forks source link

Libsql client transactions: remarks and todos #723

Open Horusiath opened 8 months ago

Horusiath commented 8 months ago

This is related to #653 . Things to discuss are:

  1. Transaction correctness. Should the begin transaction statement be batched with the first statement to save a roundtrip? IMO this messes up with the transaction execution order, since server is not aware of transactions opened on the client side. Saving a roundtrip is arguably not a big deal, since opening interactive transaction already assumes that we're going to do a "chat" with the database with multiple roundtrips involved (users can use query/execute/execute_batch for things that don't require interactivity).
  2. How should we rollback execute_batches that failed mid-way when executed within transaction scope?
  3. Extract Hrana protocol message contracts so that they could be shared between libsql client and server.
  4. How to defer Cloudflare transaction rollback on dropped transactions? Right now Transaction over Hrana HTTP variant is capable of scheduling rollback request when it's being dropped without being rolled back or committed explicitly. However that's not the case for Cloudflare workers: we need (?) to figure out a way to utilise workers API to gracefully close uncommitted transactions.
LucioFranco commented 8 months ago
  1. Clean up trait bounds
  2. Remove futures lock in favor of tokio mutex
Horusiath commented 8 months ago

@LucioFranco you're forgetting that these types are used in WASM/Cloudflare as well - there's no tokio nor Send+Sync in there.