tursodatabase / tursodatabase/libsql
If local disk is lagging behind S3, then new snapshot might overwrite the S3 snapshot
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 17.2k
- Forks
- 531
- Avg merge
- 1h 12m
- Merged PRs (30d)
- 1
Description
Say we have a database and the contents of the disk lag behind S3. That is, S3 has a snapshot taken at t2 and disk reflects some previous time t1 (this can happen if the volume is restored from Fly from a previous back up)
Here is how you can reproduce this:
- t1: Create a db and insert 5 rows. Copy the
sqld.datato some place - t2: Insert a few more rows. Total row count 10
- t3: Shutdown sqld
- Run bottomless-cli and restore the db, row count is 10, as expected
- Move t1 data into
sqld.data - t4: Restart sqld. Let it do a snapshot and upload
now on bottomless-cli, do a plain restore, it shows only 5 rows
bug:
- before snapshotting, it should check whether the current data on disk is latest than S3
- bottomless needs to restore to latest data
I think this can lead to data loss, if bottomless cleans up and deletes older-looking generations
$ bottomless-cli -n 'ns-avidb:eb4b69ea-b087-4565-ade4-a111801e6a5b' -d db ls
e4e55729-f1ee-7b13-b386-afddadbfec53 (created: 2023-10-12T08:43:10+00:00) <- t1 data
e4e55747-5808-7661-bc96-e922f40678e4 (created: 2023-10-12T08:11:03+00:00) <- t2 data
e4e55762-a1ed-794d-bc2d-26d30bf380fc (created: 2023-10-12T07:41:15+00:00) <- t1 data
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the sequence using bottomless-cli: create t1 and t2 data, restore t2, replace sqld.data with t1, then restart and snapshot. Read the snapshot and restore flow to determine how the disk generation is compared with S3. Done means a stale local disk cannot overwrite the newer remote snapshot and plain restore returns the latest data.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, rust
- Domain
- cloud, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100