rishabhdaim opened a new pull request, #3125:
URL: https://github.com/apache/jackrabbit-oak/pull/3125

   ## Summary
   
   Online revision cleanup can delete still-referenced segments on a segment 
store that was **not written in compaction order** (e.g. a promoted cold 
standby).
   
   `DefaultCleanupContext.isDanglingFutureSegment` decides which *compacted* 
segments are unused aborted-compaction leftovers by **physical scan position**: 
cleanup marks TAR entries newest-first and treats every compacted segment as 
reclaimable until the last compacted root recorded in `gc.log` is reached (the 
`aheadOfRoot` flag). This assumes segments are laid out in compaction write 
order (the compacted root written last).
   
   That assumption does not hold for a store assembled out of compaction order 
— e.g. a cold standby, whose segments are written via `FileStore.writeSegment` 
in sync-arrival order. There the recorded root is not the newest segment, so 
the reverse scan reaches live, head-referenced compacted segments while 
`aheadOfRoot` is still `true` and marks them reclaimable. Online revision 
cleanup then removes referenced segments and a subsequent read/compaction fails 
with `SegmentNotFoundException`.
   
   ## Changes
   
   - Add an order-independent, **generation-based** detection: a compacted 
segment is an unused future segment iff its generation is strictly newer than 
the head generation (`generation.compareWith(headGeneration) > 0`).
   - Gated by system property `oak.segment.cleanup.danglingByGeneration`, 
**default `false`** (no behaviour change); opt in with 
`-Doak.segment.cleanup.danglingByGeneration=true`.
   - Thread the head `GCGeneration` into `DefaultCleanupContext` (covers both 
the pre-compaction `CleanupFirstCompactionStrategy` and post-compaction 
`DefaultCleanupStrategy` paths).
   - Add `DefaultCleanupContextTest`.
   
   ## Test plan
   
   - [x] `mvn test -pl oak-segment-tar -Dtest=DefaultCleanupContextTest` — 13 
tests, green (reproduces the positional over-reclaim by default; verifies the 
generational mode retains live compacted segments while still reclaiming 
genuine future leftovers).
   
   ## Links
   
   - https://issues.apache.org/jira/browse/OAK-12400
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to