cockroachdb / pebble

RocksDB/LevelDB inspired key-value database in Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

metamorphic: use single delete instead of delete opportunistically

jbowens opened this issue · comments

Now that we have CanDeterministicallySingleDelete, we could at runtime decide to single delete instead of delete when performing a delete against a DB or an indexed batch. We'd need to create an iterator, seek to the key, and call CanDeterministicallySingleDelete.

Related to #3107.

In implementing this, I discovered that CanDeterministicallySingleDelete is flawed with obsolete bit masking. The obsolete bit masking may hide a DEL within a table that's made obsolete by higher-seqnum'd SET within the same table. If there's another SET within a lower level, the top-level Iterator will observe SET, SET and conclude that it's unsafe to single delete when it is indeed safe.

The above doesn't preclude using it within the metamorphic tests if we have an option to disable obsolete-bit masking on a per-Iterator level.

There's still a complication around MERGE keys. The current key may be the result of combining multiple merges, in which case SINGLEDEL is not deterministic. CanDeterministicallySingleDelete will need a way to observe whether the current iterator position is the result of merging.