Skip to content

Rejects batches instead of hanging when open fails - #128

Merged
kasperisager merged 4 commits into
holepunchto:mainfrom
tur-nr:fix/batch-flush-open-error
Nov 13, 2026
Merged

kasperisager merged 4 commits into
holepunchto:mainfrom
tur-nr:fix/batch-flush-open-error

Conversation

@tur-nr

@tur-nr tur-nr commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Why

When the db fails to open, for example on a locked directory, batches never settle. flush(), the operations queued on it and db.get() hang, and the open error only shows up as an unhandled rejection.

Proposal

A failed flush rejects with its error, along with everything queued on the batch.

Testing

Reads on a db whose open failed reject instead of hanging, through both a batch flush and db.get().

Notes

Bumps librocksdb to pick up holepunchto/librocksdb#45. A failed open leaked the env, which the new test's locked open surfaced under ASan.

@tur-nr
tur-nr requested a review from a team November 3, 2026 04:03
@tur-nr
tur-nr marked this pull request as draft November 3, 2026 04:04
@greptile-apps

greptile-apps Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable new issues were found.

Summary

Batches now reject when opening the database fails, rather than leaving callers waiting.

  • Failed database opens now reject batch reads and flushes.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Batch flush] --> B[Wait for database to open]
  B -->|Open fails| C[Catch flush error]
  C --> D[Reject queued operations]
  D --> E[Clear batch state]
  E --> F[Reject flush promise]
Loading

Reviews (3) · Last reviewed commit: "Update `librocksdb` to free the env when..." · Reviewed by Greptile

@tur-nr
tur-nr force-pushed the fix/batch-flush-open-error branch from 483d2ac to 778bc4e Compare November 3, 2026 10:11
@tur-nr
tur-nr marked this pull request as ready for review November 4, 2026 03:54
@kasperisager

Copy link
Copy Markdown
Contributor

@tur-nr Are you looking into the leak that trips up the tests?

@tur-nr

tur-nr commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

@kasperisager see holepunchto/librocksdb#45 I guess my test was forcing a db failure which exposed an underlaying leak in the lib.

@kasperisager

Copy link
Copy Markdown
Contributor

Great catch!

@kasperisager
kasperisager merged commit f68380b into holepunchto:main Nov 13, 2026
9 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