orbitinghail / sqlsync

SQLSync is a collaborative offline-first wrapper around SQLite. It is designed to synchronize web application state between users, devices, and the edge.
https://sqlsync.dev
Apache License 2.0
2.29k stars 30 forks source link

storage snapshots #8

Open carlsverre opened 1 year ago

carlsverre commented 1 year ago

With the rebase sync architecture, compacting the storage log is very easy and safe. At any point the coordinator can snapshot and start a new log from the snapshot.

The snapshot algorithm can work like this to improve efficiency on the clients:

This algorithm depends on the server continuing to serve the old log for some period of time - this time window determines how many clients will be able to efficiently switch over.

Since the coordinator also wants to be durable in a serverless setting, it's likely that the old logs will already be backed up to storage. Thus the coordinator can always serve from the last log lazily without keeping it in memory. (at least until GC runs and kills old logs, but that should never hit the immediately previous log)