[ 
https://issues.apache.org/jira/browse/OAK-12119?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18062057#comment-18062057
 ] 

Rishabh Daim commented on OAK-12119:
------------------------------------

The proposed fix is as follows:



*Fix*

Store the CompactionResult in the *GarbageCollector* after 
_*compactFull()/compactTail()*_ and thread it into the subsequent _*cleanup()*_ 
call.

This requires adding the 2-arg _cleanup(Context, CompactionResult)_ overload to 
the *GarbageCollectionStrategy* interface (the implementation already exists on 
{*}AbstractGarbageCollectionStrategy{*}).

 

cc [~reschke] 

> Offline Compaction does not persist compacted head into gc.log
> --------------------------------------------------------------
>
>                 Key: OAK-12119
>                 URL: https://issues.apache.org/jira/browse/OAK-12119
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>            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