HarperFast / HarperFast/rocksdb-js

Concurrent read-only discovery can recover a live transaction-log segment

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

Description

## Problem

`TransactionLogStoreRegistry` shares stores by database path across writable and read-only descriptors. When a second descriptor opens, `DiscoverStores()` calls `TransactionLogStore::load()` before the existing registry store wins `emplace`. That duplicate load opens the current segment and runs `recoverTail()` through a separate `TransactionLogFile` instance whose mutex does not coordinate with the live writer.

If discovery observes an append between frames, recovery can classify the active tail as interrupted and truncate bytes while the writable descriptor is committing.

## Impact

The race can corrupt transaction-log history or make committed entries unreachable to replication/replay. It requires concurrent writable and read-only descriptors for the same database path, but the failure is silent at the point where recovery mutates the live segment.

## Expected behavior

Discovery for a path that already has registered stores must reuse the existing store without loading and recovering the live directory again, or otherwise coordinate recovery with the active writer.

## Notes

Found during independent review of #825. The rediscovery path is present on `main` and is separate from that PR's clock-floor changes.

Contributor guide

Open the contributing guide

Research direction

Start by tracing TransactionLogStoreRegistry::DiscoverStores(), TransactionLogStore::load(), recoverTail(), and TransactionLogFile on main. Reproduce or reason through discovery of the same database path with writable and read-only descriptors. Done means discovery no longer independently loads and recovers a live segment, and concurrent commits cannot have their transaction-log bytes truncated.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.