-
Notifications
You must be signed in to change notification settings - Fork 0
Design doc: embed Litestream replication for sqlite-rest #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
bcho
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| ### High-level flow | ||
|
|
||
| 1. **Configuration** (new `ReplicationOptions`): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to consume litestream configuration file here to minimal the deltas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to prefer a Litestream YAML config via --replication-config so sqlite-rest changes stay minimal. (f01868e)
| - `--replication-restore-lag` (duration, default `0` meaning no lag allowed; used during startup restore decisions to tolerate a small amount of staleness between the local DB and the replica before forcing a restore). | ||
| - Env var mirrors for container use (e.g., `SQLITEREST_REPLICATION_ENABLED`, etc.). | ||
|
|
||
| 2. **Restore before serving**: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
describe the behavior of diverging with remote backup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added divergence behavior: default fail-fast on lineage mismatch with remote, operator can force-restore or allow degraded if they accept overwrite risk. (f01868e)
|
|
||
| ## Open questions | ||
|
|
||
| - Should we expose multiple replicas at launch or keep single-replica until requested? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
multiple replicas of what? Please clarify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarified this means multiple remote destinations for the same SQLite DB via Litestream; initial scope remains single replica. (f01868e)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this question as we have the answer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the answered question about multiple replicas; doc now just states initial scope is single replica with Litestream config controlling replicas. (d41a7dd)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the answered question; doc reflects single-replica initial scope with Litestream config controlling destinations. (d41a7dd)
| ## Open questions | ||
|
|
||
| - Should we expose multiple replicas at launch or keep single-replica until requested? | ||
| - How strict should startup be when replication is enabled but the remote is unreachable? **Recommendation:** fail fast by default to avoid running without configured durability, with an explicit `--replication-allow-degraded` escape hatch if operators need to accept the data-loss risk. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree with this decision, but we should refine the cli flag experience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flag UX is now minimal: enable + config path, optional restore-from/allow-degraded; all other tuning stays in the Litestream config. (f01868e)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this question
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the resolved question; CLI UX stays minimal via enable + config path, optional restore-from. (d41a7dd)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the resolved question per feedback. (d41a7dd)
|
|
||
| - Should we expose multiple replicas at launch or keep single-replica until requested? | ||
| - How strict should startup be when replication is enabled but the remote is unreachable? **Recommendation:** fail fast by default to avoid running without configured durability, with an explicit `--replication-allow-degraded` escape hatch if operators need to accept the data-loss risk. | ||
| - What are the sensible defaults for snapshot/retention to balance durability and cost? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaults to disable this feature, delegate the detailed settings to litestream config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documented that replication stays disabled by default and detailed settings are delegated to the Litestream config file. (f01868e)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this question
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the answered question; defaults remain disabled with detailed settings delegated to the Litestream config. (d41a7dd)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the remaining question; open questions now only cover sensible defaults for snapshot/retention. (d41a7dd)
Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
bcho
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| ## Open questions | ||
|
|
||
| - Should we expose multiple replicas at launch or keep single-replica until requested? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this question as we have the answer
| ## Open questions | ||
|
|
||
| - Should we expose multiple replicas at launch or keep single-replica until requested? | ||
| - How strict should startup be when replication is enabled but the remote is unreachable? **Recommendation:** fail fast by default to avoid running without configured durability, with an explicit `--replication-allow-degraded` escape hatch if operators need to accept the data-loss risk. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this question
|
|
||
| - Should we expose multiple replicas at launch or keep single-replica until requested? | ||
| - How strict should startup be when replication is enabled but the remote is unreachable? **Recommendation:** fail fast by default to avoid running without configured durability, with an explicit `--replication-allow-degraded` escape hatch if operators need to accept the data-loss risk. | ||
| - What are the sensible defaults for snapshot/retention to balance durability and cost? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this question
Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
bcho
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 1. **Configuration** (new `ReplicationOptions`): | ||
| - `--replication-enabled` (bool, default false). | ||
| - `--replication-config` (string, path to Litestream YAML config; preferred path to keep sqlite-rest changes minimal and delegate detailed tuning like snapshot/retention/replicas to Litestream). | ||
| - `--replication-restore-from` (optional override to restore from a different replica URL; if omitted, use the primary replica from the Litestream config). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove --replication-restore-from flag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the --replication-restore-from flag; minimal flags are now enable + config path. (61a3a12)
| - `--replication-config` (string, path to Litestream YAML config; preferred path to keep sqlite-rest changes minimal and delegate detailed tuning like snapshot/retention/replicas to Litestream). | ||
| - `--replication-restore-from` (optional override to restore from a different replica URL; if omitted, use the primary replica from the Litestream config). | ||
| - Env var mirrors for container use (e.g., `SQLITEREST_REPLICATION_ENABLED`, `SQLITEREST_REPLICATION_CONFIG`, etc.). | ||
| - Recommended CLI UX: keep flags minimal (`--replication-enabled`, `--replication-config`, optional `--replication-restore-from`) and leave all other Litestream knobs to the config file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drop this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropped the UX line tied to the removed flag; doc reflects only enable + config path. (61a3a12)
Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
The issue requests a design for embedding Litestream’s Go library to add replication/restore to sqlite-rest without altering the REST API.
--replication-config(minimal sqlite-rest flags: enable/config path); detailed tuning (snapshot/retention/replicas) delegated to Litestream config; least-privilege S3 IAM notes; multi-replica refers to multiple remote destinations for the same DB, with initial scope single.Example lifecycle sketch:
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.