Skip to content

Fix compactRange with buffer keys - #117

Merged
kasperisager merged 3 commits into
holepunchto:mainfrom
tur-nr:fix/compact-range-buffer-keys
Oct 8, 2026
Merged

kasperisager merged 3 commits into
holepunchto:mainfrom
tur-nr:fix/compact-range-buffer-keys

Conversation

@tur-nr

@tur-nr tur-nr commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Problem

compactRange() treats any object argument as options, and a Buffer is an object. So compactRange(start, end, opts) with Buffer keys uses end as the options, compacts from start to the end of the keyspace and drops the real options. A lone Buffer start is treated as options too, so the whole keyspace gets compacted.

Proposal

Only treat an argument as options when it isn't an ArrayBuffer view.

Tests

  • With three L0 files, compactRange(Buffer) and compactRange(Buffer, Buffer) only compact the files in range, checked with rocksdb.num-files-at-level0.
  • bottommostLevelCompaction: FORCE passed with Buffer keys is honoured, checked by a stale version in the bottommost level being dropped (rocksdb.estimate-num-keys).

@tur-nr
tur-nr requested a review from a team October 8, 2026 08:21
@kasperisager

Copy link
Copy Markdown
Contributor

I wonder if LSan caught a genuine leak or if it's a false positive 🤔

@tur-nr

tur-nr commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

@kasperisager should I re-run or is there something I can do locally to test against flakes with leak scanner?

@tur-nr

tur-nr commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Seems to a leak on your asan PR too, so likely not this change.

@kasperisager

Copy link
Copy Markdown
Contributor

It's a finalizer leak, I'm fixing it.

@kasperisager

Copy link
Copy Markdown
Contributor

holepunchto/libjs#71

@kasperisager
kasperisager merged commit 1f8f3a2 into holepunchto:main Oct 8, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants