HarperFast / HarperFast/rocksdb-js
Release pending transactions when NativeTransaction is garbage-collected
- Dominant language
- C++
- Stars
- 21
- Forks
- 2
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 36
Description
Parent: #741
## Problem
`Transaction::Constructor` registers every native handle in `DBDescriptor::transactions` with a strong `shared_ptr`. The `NativeTransaction` finalizer only resets the JS-side pointer. If an uncommitted transaction becomes unreachable while its database and environment remain alive, the descriptor registry keeps the handle alive, so its RocksDB transaction, snapshot, DB handle, VT intents, and transaction-log pending state can remain retained until environment or database shutdown.
PR #780 reaps these handles when their environment exits. That bounds the worker-recycle failure but does not give an abandoned transaction the lifetime of its JS owner in a long-lived environment.
## Required invariant
An unreachable, uncommitted `NativeTransaction` must not retain native transaction resources indefinitely. Cleanup must unregister and settle the handle without racing in-flight native work.
## Acceptance criteria
- Close/abort safely from the JS finalizer, or change registry ownership so the registry cannot be the last strong owner of an otherwise unreachable transaction.
- Reuse the definitive close/work synchronization established for #780/#784; do not introduce a finalizer-versus-commit race.
- Preserve explicit commit, abort, retry, outstanding-iterator, and transaction-log semantics.
- Add a forced-GC regression against a long-lived open database.
- Verify that the descriptor transaction count returns to baseline and that snapshots, VT intents, and transaction-log pending state are released.
## Relationship
- Umbrella: #741
- Environment-exit reap: #780
- Close synchronization prerequisite: #784
— KrAIs (Codex), on behalf of @kriszyp
Contributor guide
Research direction
Start with Transaction::Constructor, the NativeTransaction finalizer, and DBDescriptor::transactions, then read the close/work synchronization established for #780 and #784. Add a forced-GC regression using a long-lived open database and verify the descriptor transaction count, snapshots, VT intents, and transaction-log pending state return to baseline without changing explicit transaction semantics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, node.js
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100