benbjohnson / litestream

Streaming replication for SQLite.
https://litestream.io
Apache License 2.0
10.36k stars 232 forks source link

restore: distributed transaction across two litestream dbs #460

Closed zeroexcuses closed 1 year ago

zeroexcuses commented 1 year ago

We are running to separate litestream DBs, call them dbA, dbB.

dbA gets transactions a1, a2, ..., a100 dbB gets transactions b1, b2, .., b100

a80 / b90 is a distributed transaction -- it modifies both litestream dbs simultaneously. In particular, during restore:

A -> a81, B -> b89 is an error a -> a79, B -> b91 is an error

because in both cases, only half of the distributed transaction happened.

Question: is there anyway to do distributed transactions / restore in litestream ? We want to be able to mark certain transactions as distributed, and then have the multiple litestream restores to sync so that the transaction is all-or-nothing across multiple litestream dbs.

benbjohnson commented 1 year ago

@zeroexcuses Litestream is meant to be used for disaster recovery on a single node. If you need multiple writers, you'll need to look into something like Mycelial. There's also LiteFS but that's still a single writer but with read replicas.