Cross-thread lock-release and parked-commit wakes use unref'd threadsafe functions — a waiting thread's event loop can drain and exit before the wake arrives
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 68/100
Research direction
Read DBDescriptor::lockEnqueueCallback in db_descriptor.cpp and the coordinated-retry RETRY_NOW TSFN handling in transaction.cpp, then compare both with DBDescriptor::registerCommitCompletion. Trace how each pending wake is created, delivered, and cancelled; done means outstanding waits keep the waiting event loop alive while idle registrations remain unref'd.
Written by the indexing model from the issue text.
Description
Problem
Two cross-thread wake paths deliver their completion through threadsafe functions that are napi_unref_threadsafe_function'd at creation:
- Lock-release wakes —
DBDescriptor::lockEnqueueCallback(db_descriptor.cpp,NAPI_STATUS_THROWS_VOID(::napi_unref_threadsafe_function(env, threadsafeCallback))right after creation): theonUnlockedcallback a waiter enqueues viaStore.tryLock(key, onUnlocked)/withLock(). - Parked-commit retry wakes — the coordinated-retry
RETRY_NOWTSFN inTransactioncommit completion (transaction.cpp,::napi_unref_threadsafe_function(env, tsfn)afternapi_create_threadsafe_function): a commit that hitIsBusyparks on the conflicting holder's VT-slot lock and resolves when the holder releases.
In both cases the waiting thread has real pending work — a promise that will be resolved by another thread's action — but contributes nothing to its own event loop's liveness. If the waiter has no other ref'd handle at that moment, its loop drains and the thread exits cleanly before the wake arrives. The wake then fires into a dead env (or is dropped).
This is the root cause of HarperFast/harper#2312: a Harper worker thread parked on a peer worker's lock during concurrent multi-worker startup (a pre-ready worker owns no ref'd handles) exits with code 0 before its ready handshake, aborting the whole node's boot — currently the top non-Windows CI failure on harper main. Post-ready workers survive the identical parking only because unrelated ref'd handles (parentPort, listeners) happen to hold their loops.
Compare DBDescriptor::registerCommitCompletion, which gets this right: the commit-completion TSFN is ref'd while a commit is pending and unref'd when the pending count returns to zero.
Expected
A pending cross-thread wake (enqueued lock callback, parked commit) should keep the waiting thread's event loop alive until delivered — ref the TSFN while the wait is outstanding and unref on delivery/cancel, mirroring the pending-commit-completion pattern. Idle registrations (no waiter outstanding) should stay unref'd so threads can still exit normally.
harper is landing a defense-in-depth fix (holding a ref through its workers' pre-ready window), but the library-level contract — "an awaited rocksdb-js operation keeps the loop alive" — belongs here.
- Dominant language
- C++
- Stars
- 24
- Forks
- 3
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 46
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from HarperFast/rocksdb-js
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
HarperFast/rocksdb-js#964 ·
Maintainers usually reply within 1 day
-
Transaction committedPosition is the watermark key, not the batch's first-entry addressPossibly taken @kriszyp claimed this 1 day ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
HarperFast/rocksdb-js#961 · 1 assignee ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
HarperFast/rocksdb-js#945 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
HarperFast/rocksdb-js#972 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
HarperFast/rocksdb-js#968 ·
Maintainers usually reply within 1 day
All issues in HarperFast/rocksdb-js
Similar issues
-
自定义颜色添加为常用颜色Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
mg-chao/snow-apps#2227 · 2 comments ·
Maintainers usually reply within 1 day
-
crash lld:COFF
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
llvm/llvm-project#235970 · 1 comment ·
Maintainers usually reply within 1 day
-
[Bug]: iOS textarea wraps text mid-word because LynxUIBaseInput hardcodes NSLineBreakByCharWrappingOpen
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
lynx-family/lynx#10455 ·
Maintainers usually reply within 1 day
-
[DocDB] C++ tests that run the YSQL Connection Manager do not build odyssey or its config templateOpenarea/docdb kind/bug priority/medium status/awaiting-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
yugabyte/yugabyte-db#35861 ·
Maintainers usually reply within 1 day
-
A-tools P-low S-blocked task
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day