Skip to content

Commit

Permalink
fix tests and restore performance
Browse files Browse the repository at this point in the history
  • Loading branch information
staltz committed Apr 19, 2022
1 parent 35c5b3b commit 5d79ab7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions test/compaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion test/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5d79ab7

Please sign in to comment.