Write-ahead log with fsync batching for Eio

Fix off-by-one in WAL block boundary check #1

open opened by vblt.org targeting main from vblt.org/ocaml-wal: fix-block-boundary-off-by-one

When exactly header_size (7) bytes remain in a block, avail = 0 causes a 0-length fragment → Invalid_argument("empty record"). Fix: < → <= to pad and skip to the next block. By Claude

Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:2y4mz22jpogkz2ia3xhcfshw/sh.tangled.repo.pull/3mgppeljyma22
+1 -1
Diff #0
+1 -1
lib/wal.ml
··· 103 103 else 104 104 (* Space left in current block *) 105 105 let block_remaining = block_size - t.block_offset in 106 - if block_remaining < header_size then begin 106 + if block_remaining <= header_size then begin 107 107 (* Not enough space for header, pad and move to next block *) 108 108 let padding = String.make block_remaining '\x00' in 109 109 Eio.File.pwrite_all t.file ~file_offset:t.file_offset

History

1 round 0 comments
sign up or login to add to the discussion
vblt.org submitted #0
1 commit
expand
Fix off-by-one in WAL block boundary check
no conflicts, ready to merge
expand 0 comments