Author: mduerig Date: Sat Oct 31 16:44:09 2015 New Revision: 1711654 URL: http://svn.apache.org/viewvc?rev=1711654&view=rev Log: OAK-3372: Collapsing external events in BackgroundObserver even before queue is full leads to JournalEntry not getting used Make *not* collapsing external events the default. Credits to Vikas Saurabh for the patch.
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/BackgroundObserver.java Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/BackgroundObserver.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/BackgroundObserver.java?rev=1711654&r1=1711653&r2=1711654&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/BackgroundObserver.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/BackgroundObserver.java Sat Oct 31 16:44:09 2015 @@ -49,8 +49,9 @@ import org.slf4j.LoggerFactory; * to fill up, any further update will automatically be merged into just one * external content change, causing potential loss of local commit information. * To help prevent such cases, any sequential external content changes that - * the background observer thread has yet to process are automatically merged - * to just one change. + * the background observer thread has yet to process are optionally + * (see {@code alwaysCollapseExternalEvents} and {@code oak.observation.alwaysCollapseExternal}) + * automatically merged to just one change. */ public class BackgroundObserver implements Observer, Closeable { @@ -84,6 +85,12 @@ public class BackgroundObserver implemen */ private final int maxQueueLength; + /** + * Whether external events should be collapsed even if queue isn't full yet. + */ + private final boolean alwaysCollapseExternalEvents = + Boolean.parseBoolean(System.getProperty("oak.observation.alwaysCollapseExternal", "false")); + private static class ContentChange { private final NodeState root; private final CommitInfo info; @@ -254,7 +261,7 @@ public class BackgroundObserver implemen checkState(!stopped); checkNotNull(root); - if (info == null && last != null && last.info == null) { + if (alwaysCollapseExternalEvents && info == null && last != null && last.info == null) { // This is an external change. If the previous change was // also external, we can drop it from the queue (since external // changes in any case can cover multiple commits) to help