[ https://issues.apache.org/jira/browse/OAK-11169?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17887332#comment-17887332 ]
Julian Reschke commented on OAK-11169: -------------------------------------- OK, I found why "findModifiedDocsWhenModifiedIsDifferent()" does not fail; it checks for the oldest document, but creates nodes in (almost) alphabetical order, so that sorting is not needed, and thus the invalid sort statement (not causing an exception in the older driver) has no effect. > MongoVersionGCSupport (oak-document-store) wrong syntax for sort mongodb > function > --------------------------------------------------------------------------------- > > Key: OAK-11169 > URL: https://issues.apache.org/jira/browse/OAK-11169 > Project: Jackrabbit Oak > Issue Type: Bug > Components: mongomk > Reporter: Raffaele Gambelli > Priority: Major > > In the MongoVersionGCSupport class, there is a wrong symtax in using the sort > function of mongodb. > {code:java} > final Bson sort = and(eq(MODIFIED_IN_SECS, 1), eq(ID, 1)); > // we need to add query condition to ignore `previous` documents which > doesn't have this field > final Bson query = exists(MODIFIED_IN_SECS); > FindIterable<BasicDBObject> limit = > getNodeCollection().find(query).sort(sort).limit(1); > {code} > in the $sort you can't insert $and, here it is the syntax of > [$sort|https://www.mongodb.com/docs/manual/reference/operator/aggregation/sort] > [ERROR] Failures: > [ERROR] VersionGCSupportTest.findModifiedDocsWhenModifiedIsDifferent:288 > expected:<40> but was:<0> > [ERROR] VersionGCSupportTest.findModifiedDocsWhenOldestDocIsPresent:323 > expected:<40> but was:<0> > [ERROR] VersionGCSupportTest.findOldestModified:265 diff (s) should be < 5: > 1234567 > [ERROR] Errors: > [ERROR] VersionGCSupportTest.findModifiedDocsWhenOldestDocIsAbsent:376 ┬╗ > MongoQuery Co... > [ERROR] > VersionGCSupportTest.getPossiblyModifiedDocs:166->assertModified:398 ┬╗ > MongoQuery > and here the mongo exception: > {noformat} > [ERROR] getPossiblyModifiedDocs[MongoFixture: > MongoDB](org.apache.jackrabbit.oak.plugins.document.VersionGCSupportTest) > Time elapsed: 0.208 s <<< ERROR! > com.mongodb.MongoQueryException: Command failed with error 15974 > (Location15974): 'Illegal key in $sort specification: $and: [ { _modified: 1 > }, { _id: 1 } ]' on server localhost:62097. The full response is {"ok": 0.0, > "errmsg": "Illegal key in $sort specification: $and: [ { _modified: 1 }, { > _id: 1 } ]", "code": 15974, "codeName": "Location15974"} > {noformat} -- This message was sent by Atlassian Jira (v8.20.10#820010)