purgeLogs({destroy:true}) continuing past a refused unlink can strand readers or leave stale flushed-state generation
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 32/100
Research direction
Read transaction_log_store.cpp around the sequenceFiles.empty() check in doPurge(), then inspect removeFileLocked() in transaction_log_file_posix.cpp and transaction_log_file_windows.cpp at the referenced ranges. Decide which refusal contract applies, trace both destroy:true hazards, and validate that the chosen behavior preserves reader mappings and flushed-state state consistently.
Written by the indexing model from the issue text.
Description
Problem
TransactionLogStore::doPurge()'s destructive path (purgeLogs({ destroy: true }), all=true) continues past a segment whose unlink is refused (EACCES, or a Windows sharing violation while a bound transaction keeps the store alive) instead of stopping. That non-throwing continue-past-refusal behavior (introduced in HarperFast/rocksdb-js#820 to make Windows purge-vs-mapping convergence testable) creates two independent hazards, both destroy: true-only:
-
A refused unlink of the current segment strands a reader on a stale mapping.
removeFileLocked()(transaction_log_file_posix.cpp/transaction_log_file_windows.cpp) drops the strongmemoryMapand closes the fd before it knows whether the unlink succeeded. If the current segment's unlink is refused while a bound transaction keeps the store alive, the next append reopens the file into a newMemoryMap; a reader still holding the old buffer never sees the new entries, because its extent and overlay stop advancing. -
A refused unlink of an older segment can leave a stale flushed-state generation authoritative. The flushed-state generation bump, correlation-ring reset, and
txn.stateclear (transaction_log_store.cpp, around thesequenceFiles.empty()check indoPurge()) only run when the destructive purge empties the registered set entirely. If one older segment's unlink is refused (leavingsequenceFilesnon-empty) while a later, already-flushed segment is still successfully deleted, that whole invalidation block is skipped —txn.statesurvives naming the deleted segment's sequence number. After a restart, the refused segment becomes current, a later append can reuse the now-vacant sequence numbertxn.statestill names, and retention can then delete that reused segment as "already flushed" before it reaches RocksDB.
Impact
Both require purgeLogs({ destroy: true }), which Harper does not call in production, so neither is currently reachable in the field. But they are real correctness gaps in a public API: #1 silently truncates a reader's view of committed history; #2 can cause retention to delete unflushed, acknowledged data after a restart.
Expected behavior
Pick one destroy-refusal contract and apply it consistently to both hazards:
- Stop-at-first-refusal — restore
main's pre-#820 effective behavior (throw on a refused unlink during a destructive purge) so a partial destroy can never leave state describing an inconsistent segment set. Simple, but means one stuck segment blocks the whole destroy. - Fine-grained invalidation — invalidate the flushed-state generation whenever the specific segment
txn.statenames is removed (not only when the whole registered set empties), and retain/restore the tracked mapping for a segment whose unlink failed (don't dropmemoryMapuntil the unlink actually succeeds). Lets destroy continue past an unrelated stuck segment, at the cost of more state to keep consistent.
Notes
Surfaced during independent review (codex + harper-domain, multiple rounds) while maintaining #820. Deliberately not fixed inside that PR: #820 is scoped to the purge/read-coherence contract for the retention path Harper actually uses, and prior attempts at hardening the destroy: true path inside that PR repeatedly surfaced new races (documented there as a scope correction). Decision recorded: defer, track here — HarperFast/rocksdb-js#820 (comment thread) has the fuller review trail and code references (transaction_log_store.cpp:842, transaction_log_file_posix.cpp:510-534, transaction_log_file_windows.cpp:523-565).
- 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
-
Rifle-variant weapon offsets are saved under the pistol's name [FRIK-093]Possibly taken @rollingrock claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
rollingrock/Fallout-4-VR-Body#182 ·
-
[Bug] [Go] Ack returns nil when the server answers with a non-OK statusPossibly taken @leizhiyuan claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
apache/rocketmq-clients#1465 ·
Maintainers usually reply within 2 days
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
cp-algorithms/cp-algorithms#1738 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
KhronosGroup/Vulkan-Tutorial#534 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 2 days