HarperFast / HarperFast/rocksdb-js

Wait for the stall-watchdog test child to close before removing its database

Open
#863 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
21
Forks
2
Avg merge
2d 9h
Merged PRs (30d)
36

Description

The WriteBufferManager stall-watchdog test can fail during temporary database cleanup on Bun/Windows because `runStallChild()` resolves as soon as it sends `SIGKILL`, before observing the child's `close` event. The caller immediately removes the database directory, potentially racing the still-running child and its open handles. A cleanup exception also masks the watchdog assertions that follow the `finally` block.

Observed on Bun 1.4.2, Windows x64, RocksDB 11.8.1 in [PR #862's CI job](https://github.com/HarperFast/rocksdb-js/actions/runs/35178804535/job/105066312389), at head `b2825a1a346bd603d86d1474bb263182a5c40406` (merge ref `4a09254`). The failing case was `WriteBufferManager stall watchdog > keeps reporting while shutdown waits for a stalled writer`, with `EBUSY: resource busy or locked, rm` at `test/write-buffer-manager-stall-watchdog.test.ts:216`. The failure persisted past the existing `rmSync` retry options. This is a confirmed cleanup failure; the exact Windows handle responsible was not captured.

The ordering defect already exists in [main at b4d1045, runStallChild](https://github.com/HarperFast/rocksdb-js/blob/b4d104562e7d5353b6d7a4412e0a8b48ee805062/test/write-buffer-manager-stall-watchdog.test.ts#L34): `finish()` sends the kill signal and resolves immediately. The `close` event is wired to the same already-settled function, so callers do not wait for it. The adjacent `runExitChild()` helper resolves from `close`, which is the intended pattern. PR #862 does not modify this test, and its latest commit changes comments only; no main CI reproduction is claimed.

Suggested fix: separate requesting termination from completing the result, resolve only after child close/reaping, and retain a bounded hard deadline and useful captured output for failure diagnostics. Do not merely lengthen deletion retries or suppress cleanup errors. Verify success, deadline, and spawn-error paths; run the test on Bun/Windows so the directory removal is exercised after child closure.

The same job's first suite attempt also reported an unexpected Vitest fork-worker exit. Its cause is unknown and is not attributed to this cleanup race. The cleanup error occurred on the workflow's built-in second attempt. A targeted CI-job rerun has been requested.

Priority: P2 — a contained, visible CI/test-lifecycle defect that can mask the real assertion and leave a child or temporary database behind; no production data loss or customer incident is established. No release milestone or owning epic is currently identified. No customer or security context applies.

Contributor guide

Open the contributing guide

Research direction

Start in test/write-buffer-manager-stall-watchdog.test.ts at runStallChild() and compare it with the adjacent runExitChild() helper. Run the targeted “WriteBufferManager stall watchdog” test, then verify success, deadline, and spawn-error paths. Done means the child is closed before database removal, useful output is retained, and Bun/Windows no longer produces EBUSY or masks watchdog assertions.

Written by the indexing model from the issue text.

Assessment

Tech stack
bun, node.js, typescript
Domain
databases, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.