You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by da...@apache.org on 2023/06/19 08:15:49 UTC

[jackrabbit-oak] 06/08: OAK-10199 : ignore documents which doesn't have _modified field in mongo while fetching modifiedDocs

This is an automated email from the ASF dual-hosted git repository.

daim pushed a commit to branch OAK-10199
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git

commit 1d47af5a8466db9506d45d5653bfc98e7086daa8
Author: Rishabh Kumar <di...@adobe.com>
AuthorDate: Tue May 30 20:02:13 2023 +0530

    OAK-10199 : ignore documents which doesn't have _modified field in mongo while fetching modifiedDocs
---
 .../oak/plugins/document/mongo/MongoVersionGCSupport.java     | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoVersionGCSupport.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoVersionGCSupport.java
index 4d01e5d3da..324ade704c 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoVersionGCSupport.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoVersionGCSupport.java
@@ -19,6 +19,8 @@
 
 package org.apache.jackrabbit.oak.plugins.document.mongo;
 
+import static com.mongodb.client.model.Filters.eq;
+import static com.mongodb.client.model.Filters.exists;
 import static java.util.Optional.ofNullable;
 import static java.util.concurrent.TimeUnit.SECONDS;
 import static org.apache.jackrabbit.guava.common.collect.Iterables.concat;
@@ -142,7 +144,7 @@ public class MongoVersionGCSupport extends VersionGCSupport {
         // _modified >= fromModified && _modified < toModified
         final Bson query = and(gte(MODIFIED_IN_SECS, getModifiedInSecs(fromModified)),
                 lt(MODIFIED_IN_SECS, getModifiedInSecs(toModified)));
-        final Bson sort = Filters.eq(MODIFIED_IN_SECS, 1);
+        final Bson sort = eq(MODIFIED_IN_SECS, 1);
         final FindIterable<BasicDBObject> cursor = getNodeCollection()
                 .find(query)
                 .sort(sort)
@@ -233,10 +235,13 @@ public class MongoVersionGCSupport extends VersionGCSupport {
     public long getOldestModifiedTimestamp(final Clock clock) {
         LOG.info("getOldestModifiedTimestamp() <- start");
 
-        final Bson sort = Filters.eq(MODIFIED_IN_SECS, 1);
+        final Bson sort = eq(MODIFIED_IN_SECS, 1);
         final List<Long> result = new ArrayList<>(1);
 
-        getNodeCollection().find().sort(sort).limit(1).forEach(
+        // we need to add query condition to ignore `previous` documents which doesn't have this field
+        final Bson query = exists(MODIFIED_IN_SECS);
+
+        getNodeCollection().find(query).sort(sort).limit(1).forEach(
                 (Consumer<BasicDBObject>) document ->
                         ofNullable(store.convertFromDBObject(NODES, document))
                                 .ifPresent(doc -> {