benbjohnson/litestream

Replica snapshot interval should sync to previous snapshot

hifi opened this issue · 1 comments

hifi commented

Noticed a weird pattern that we hadn't gotten any snapshots for a couple of days. This was due to setting high retention time (multiple days) but 24 hour snapshot interval.

What actually happened from what I understand is that when we made releases within 24 hours of the previous one Litestream got restarted each time and as the snapshot interval begins on startup and doesn't try to find the previous snapshot from the replica first it pushed the next snapshot time so far in the future that we had a single WAL stream that spanned multiple wall clock snapshot intervals.

This doesn't cause data loss but it does make the storage pattern weird and restore times longer when that keeps happening for a long time.

I suggest changing the startup pattern to check the current generation latest snapshot time with maxSnapshot and if there's one sync the ticker to that.

Noticed a weird pattern that we hadn't gotten any snapshots for a couple of days. This was due to setting high retention time (multiple days) but 24 hour snapshot interval.

What actually happened from what I understand is that when we made releases within 24 hours of the previous one Litestream got restarted each time and as the snapshot interval begins on startup and doesn't try to find the previous snapshot from the replica first it pushed the next update snapshot time so far in the future that we had a single WAL stream that spanned multiple wall clock snapshot intervals.

This doesn't cause data loss but it does make the storage pattern weird and restore times longer when that keeps happening for a long time.

I suggest changing the startup pattern to check the current generation latest snapshot time with maxSnapshot and if there's one sync the ticker to that.