[ 
https://issues.apache.org/jira/browse/OAK-12121?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Rishabh Daim updated OAK-12121:
-------------------------------
    Issue Type: Task  (was: Bug)

> Write a test case to produce that Offline Compaction does not persist 
> compacted head into gc.log
> ------------------------------------------------------------------------------------------------
>
>                 Key: OAK-12121
>                 URL: https://issues.apache.org/jira/browse/OAK-12121
>             Project: Jackrabbit Oak
>          Issue Type: Task
>            Reporter: Rishabh Daim
>            Assignee: Rishabh Daim
>            Priority: Critical
>
> *Root Cause*
>  The offline compaction in *Compact.run()* calls *compactFull()* and 
> *cleanup()* as two separate calls, but the _CompactionResult_ from compaction 
> is silently discarded between them.
>  
> *Call chain:*
>   Compact.run()
>     ├─ store.compactFull()
>     │    └─ garbageCollector.compactFull(strategy).isSuccess()
>     │                                              ^^^^^^^^^^^
>     │         CompactionResult.succeeded(...) is returned but thrown away!
>     │
>     └─ store.cleanup()
>          └─ garbageCollector.cleanup(strategy)
>               └─ strategy.cleanup(context)   ← no-arg overload
>                    └─ AbstractGarbageCollectionStrategy.cleanup(Context):
>                         return cleanup(context, CompactionResult.skipped(...))
>                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
>                                                 Always creates a SKIPPED 
> result!
>  
> Why *gc.log* is never written:
>   In *AbstractGarbageCollectionStrategy.java:88–95:*
>   // Standalone cleanup always creates a SKIPPED result
>  
> {code:java}
> public List<String> cleanup(Context context) throws IOException {
>       return cleanup(context, CompactionResult.skipped(...));
>   }{code}
>   *CompactionResult.skipped(...)* inherits *requiresGCJournalEntry()* from 
> the base class, which returns false (line 216).
> Then in *newCleanupStrategyContext()* at line 295–297:
>  
> {code:java}
> public GCJournal getGCJournal()
> {       return compactionResult.requiresGCJournalEntry() ? 
> context.getGCJournal() : null;       //  ↑ false for skipped → returns null!  
>  }{code}
>   *DefaultCleanupStrategy* receives null for gcJournal, so it skips the 
> gcJournal.persist(...) call entirely.
>   Contrast with online (integrated) GC:
> The *AbstractGarbageCollectionStrategy.run()* method calls *cleanup(context, 
> compactionResult)* with the actual *CompactionResult.succeeded(...)* — that's 
> why gc.log works online
>   but not offline.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to