tursodatabase / libsql

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

libsql: Add max_write_replication_index and sync_until in Database #1665

Closed haaawk closed 1 month ago

haaawk commented 1 month ago

Database::max_write_replication_index can be used by the client to keep track of the lowest replication index that guarantees seeing all the writes done by this client. Database::sync_until can be then used to sync the embedded replica at least to the replication index given by the client.

That way a client can:

  1. Do a bunch of operations on one embedded replica
  2. Fetch the max_write_replication index I
  3. Run sync_until with a given replication index I on a different embedded replica and be sure that they see all the operations they've done on the first embedded replica.