tursodatabase/libsql

Make write imply sync by default

penberg opened this issue · 4 comments

nickmazuk on Discord writes:

With embedded replicas, is it possible to both write and sync with the main database in a single round trip?

Currently it seems like this requires two round trips which would increase latency where you want to write then immediately requery the database.

I don't know what the API should look like, but we should definitely support this.

Yeah, makes sense. Perhaps we could just pipeline a write and a sync request? So that we send both in one go, and then receive both the write result and synced frames

In the Discord thread, @glommer mentioned:

Depends on the guarantees you need. Syncing in the background is fine, but then with the current model you may not see some of your writes reflected on the database. I personally believe write should imply sync, though

In my opinion, writes implying a sync is an interesting proposition and would definitely solve this for my use case.

Perhaps the best API is a configuration option in the client setup? It would definitely prevent bugs where a programmer reads a stale value immediately after a write (and forgets to manually sync).

@psarna I think at the very least a write that doesn't sync should not be the default - if it is possible at all. It's just too error prone

love you all!