This is an automated email from the ASF dual-hosted git repository. daim pushed a commit to branch OAK-10378 in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit 3e66cc5ff0a1f4923cde75c7f34a130835e3db6e Author: Rishabh Kumar <d...@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 -> {