ssbc / ssb-db2

A new database for secure-scuttlebutt
47 stars 8 forks source link

After compaction, leveldb index should immediately set index.offset to -1 #355

Closed staltz closed 2 years ago

staltz commented 2 years ago

Replacing

https://github.com/ssbc/ssb-db2/blob/f976aac9a4bd4ee804b9f4cd24511dec52cb5d9d/test/compaction.js#L203

with

  await pify(sbot.db.onDrain)('aboutSelf')

SHOULD work but it doesn't. The reason is that plugin.reset() only sets offset to -1 after leveldb.clear(), but it should do that before. Otherwise, updateIndexes will see that this index is already "caught up" with the latest log.since.value.

By the way, log.since.value is NOT reset after compaction and it seems it really should be!