You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Julian Reschke (Jira)" <ji...@apache.org> on 2024/10/07 07:11:00 UTC

[jira] (OAK-11169) MongoVersionGCSupport (oak-document-store) wrong syntax for sort mongodb function

    [ https://issues.apache.org/jira/browse/OAK-11169 ]


    Julian Reschke deleted comment on OAK-11169:
    --------------------------------------

was (Author: reschke):
Note that there are two instances of that sort expression.

Maybe it needs to be split into two expressions, and then "sort()" be applied twice?

> 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)