From 8adc3de763b2535ecc347983b82d82f31fd99889 Mon Sep 17 00:00:00 2001 From: Andre Staltz Date: Thu, 14 Apr 2022 18:39:11 +0300 Subject: [PATCH] fix tests and restore performance --- index.js | 2 +- test/compaction.js | 10 +++++----- test/delete.js | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 949784c..82846c0 100644 --- a/index.js +++ b/index.js @@ -268,7 +268,6 @@ module.exports = function AsyncAppendOnlyLog(filename, opts) { if (err) return cb(err) const actualBlockBuf = blocksWithDeletables.get(blockIndex) || blockBuf Record.overwriteWithZeroes(actualBlockBuf, getOffsetInBlock(offset)) - mergeDeletedRecords(actualBlockBuf) blocksWithDeletables.set(blockIndex, actualBlockBuf) scheduleFlushDelete() cb() @@ -331,6 +330,7 @@ module.exports = function AsyncAppendOnlyLog(filename, opts) { blocksWithDeletables.delete(blockIndex) blocksWithDeletables.set(-1, null) // indicate that flush is active + mergeDeletedRecords(blockBuf) writeWithFSync(blockStart, blockBuf, null, function flushedDelete(err) { blocksWithDeletables.delete(-1) // indicate that flush is not active if (err) { diff --git a/test/compaction.js b/test/compaction.js index 9070e3f..15132d8 100644 --- a/test/compaction.js +++ b/test/compaction.js @@ -162,13 +162,13 @@ tape('shift many blocks', async (t) => { // block 0 [0x11, 0x22, 0x33], // block 1 - [0x44, null, null], + [0x44, null, 0x77], // block 2 - [0x77, 0x88, 0x99], + [0x88, 0x99, 0xaa], // block 3 - [0xaa, null, 0xcc], + [null, 0xcc, 0xdd], // block 4 - [0xdd, 0xee, 0xff], + [0xee, 0xff], ].flat(), 'log has 5 blocks and some holes' ) @@ -282,7 +282,7 @@ tape('cannot read truncated regions of the log', async (t) => { // block 0 [0x11, 0x22, 0x33], // block 1 - [0x44, null, null], + [0x44, null], // block 2 [null, 0x88, 0x99], ].flat(), diff --git a/test/delete.js b/test/delete.js index 7436a52..6f8a578 100644 --- a/test/delete.js +++ b/test/delete.js @@ -230,7 +230,7 @@ tape('merge consecutive deletes', async function (t) { t.error(err2) const [err3] = await run(log.del)(offset3) t.error(err3) - await run(log.onDrain)() + await run(log.onDeletesFlushed)() const [errB2, blockAfter] = await run(log.getBlock)(0) t.error(errB2)