polarsignals / frostdb

❄️ Coolest database around 🧊 Embeddable column database written in Go.
Apache License 2.0
1.29k stars 65 forks source link

wal: correctly set nextTx on Truncate #866

Closed asubiotto closed 3 months ago

asubiotto commented 3 months ago

On Truncate(k), if k was logged to the WAL the behavior is unchanged. However, if k had not yet been logged to the WAL, the WAL performed a full reset of the WAL and set the next expected txn to k+1. This is incorrect, since the semantics of truncate are that k becomes the first entry in the WAL after truncation.

asubiotto commented 3 months ago

This was found by DST and fixes a data loss bug (previously k would've been incorrectly dropped after a snapshot)