Shivam created OAK-12408:
----------------------------
Summary: Standalone cleanup() never journals gc.log leading to
SNFE on cold standby / backup
Key: OAK-12408
URL: https://issues.apache.org/jira/browse/OAK-12408
Project: Jackrabbit Oak
Issue Type: Bug
Components: segment-tar
Affects Versions: 2.6.0
Reporter: Shivam
Assignee: Rishabh Daim
{{DefaultCleanupContext.isDanglingFutureSegment}} detects unused
(aborted-compaction) segments by
scan position: during cleanup, TAR entries are marked newest-first and every
compacted segment is
treated as reclaimable until the last compacted root recorded in {{gc.log}} is
reached (the
{{aheadOfRoot}} flag). This assumes segments are physically laid out in
compaction write order
(the compacted root written last).
That assumption does not hold for a segment 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 compacted 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}}.
h4. Steps to reproduce
# Promote a cold standby to primary (its segment store was assembled via
standby sync).
# Run online (full) revision cleanup.
Cleanup removes still-referenced compacted segments; the following compaction
throws
{{SegmentNotFoundException}} while traversing the head. {{oak-run check}}
passes immediately before
cleanup.
h4. Suggested fix
Make the dangling-segment test generation-based rather than positional: treat a
compacted segment as
an unused future segment only if its generation is strictly newer than the head
generation. This is
independent of physical segment write order and consistent for all store types.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)