4

Following on from "How to update collection and increment hours for ISO date".

It seem that RoboMongo can't execute a query with an array filter:

RoboMongo error

This same query if find when executed through the Mongo shell though:

> db.collection.update({
...     "results.score": {
...         "$exists": true
...     }
... }, {
...     "$mul": {
...         "results.$[result].score": 10
...     }
... }, {
...     "arrayFilters": [{
...         "result.score": {
...             "$exists": true
...         }
...     }],
...     "multi": true
... })
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })

Looking at the logging in the Mongo server, it looks like the query is passed over correctly, but still fails:

D COMMAND  [conn4] run command test.$cmd { update: "collection", updates: [ { q: { results.score: { $exists: true } }, u: { $mul: { results.$[result].score: 10.0 } }, multi: true, upsert: false } ], ordered: true, $db: "test" }
D -        [conn4] User Assertion: 2:No array filter found for identifier 'result' in path 'results.$[result].score' src\mongo\db\update\update_driver.cpp 132
D WRITE    [conn4] Caught Assertion in update: BadValue: No array filter found for identifier 'result' in path 'results.$[result].score'
I WRITE    [conn4] update test.collection appName: "MongoDB Shell" command: { q: { results.score: { $exists: true } }, u: { $mul: { results.$[result].score: 10.0 } }, multi: true, upsert: false } exception: No array filter found for identifier 'result' in path 'results.$[result].score' code:BadValue numYields:0 locks:{} 4ms
D REPL     [conn4] Waiting for write concern. OpTime: { ts: Timestamp(0, 0), t: -1 }, write concern: { w: 1, wtimeout: 0 }
I COMMAND  [conn4] command test.$cmd appName: "MongoDB Shell" command: update { update: "collection", updates: [ { q: { results.score: { $exists: true } }, u: { $mul: { results.$[result].score: 10.0 } }, multi: true, upsert: false } ], ordered: true, $db: "test" } numYields:0 reslen:183 locks:{} protocol:op_command 7ms
D COMMAND  [conn4] run command test.$cmd { getlasterror: 1.0, w: 1.0, $readPreference: { mode: "secondaryPreferred" }, $db: "test" }
I COMMAND  [conn4] command test.$cmd appName: "MongoDB Shell" command: getLastError { getlasterror: 1.0, w: 1.0, $readPreference: { mode: "secondaryPreferred" }, $db: "test" } numYields:0 reslen:169 locks:{} protocol:op_command 0ms

The logs from the shell are different:

D COMMAND  [conn8] run command test.$cmd { update: "collection", ordered: true, $db: "test" }
D STORAGE  [conn8] NamespaceUUIDCache: registered namespace test.collection with UUID a5f7f2ef-a7e3-4189-a9c4-29fdb5a18db9
D QUERY    [conn8] Only one plan is available; it will be run but will not be cached. query: { results.score: { $exists: true } } sort: {} projection: {}, planSummary: COLLSCAN
D STORAGE  [conn8] WT begin_transaction for snapshot id 367
D STORAGE  [conn8] WT commit_transaction for snapshot id 367
D STORAGE  [conn8] WT begin_transaction for snapshot id 368
D STORAGE  [conn8] WT rollback_transaction for snapshot id 368
I WRITE    [conn8] update test.collection appName: "MongoDB Shell" command: { q: { results.score: { $exists: true } }, u: { $mul: { results.$[result].score: 10.0 } }, arrayFilters: [ { result.score: { $exists: true } } ], multi: true, upsert: false } planSummary: COLLSCAN keysExamined:0 docsExamined:1 nMatched:1 nModified:1 numYields:0 locks:{ Global: { acquireCount: { r: 1, w: 1 } }, Database: { acquireCount: { w: 1 } }, Collection: { acquireCount: { w: 1 } } } 3ms
D REPL     [conn8] Waiting for write concern. OpTime: { ts: Timestamp(0, 0), t: -1 }, write concern: { w: 1, wtimeout: 0 }
I COMMAND  [conn8] command test.$cmd appName: "MongoDB Shell" command: update { update: "collection", ordered: true, $db: "test" } numYields:0 reslen:44 locks:{ Global: { acquireCount: { r: 1, w: 1 } }, Database: { acquireCount: { w: 1 } }, Collection: { acquireCount: { w: 1 } } } protocol:op_msg 4ms
D COMMAND  [conn8] run command test.$cmd { isMaster: 1.0, forShell: 1.0, $db: "test" }
D NETWORK  [conn8] Starting server-side compression negotiation
D NETWORK  [conn8] Compression negotiation not requested by client
I COMMAND  [conn8] command test.$cmd appName: "MongoDB Shell" command: isMaster { isMaster: 1.0, forShell: 1.0, $db: "test" } numYields:0 reslen:208 locks:{} protocol:op_msg 1ms

I can't see anything that would imply that something is wrong though (other than the assertion failure of course).

  • What's causing RoboMongo to fail where Mongo shell succeeds?
  • Is there anything in these logs that tells me what's wrong?
4
  • do robomongo have support for 3.6 ? the latest version supports only 3.4 Commented Jan 18, 2018 at 13:54
  • @Veeram thanks (I hadn't actually checked), I wanted to know what the problem was though, what's special about this as opposed other update queries? Commented Jan 18, 2018 at 13:58
  • @Veeram I'd assumed that RoboMongo will just throw queries over to the server. Commented Jan 18, 2018 at 13:59
  • 3
    No, not really. Not sure arrayFilters is backward compatible change. Robomongo is shell based product but it has its own wrapper around mongo shell and some parsing happens before queries are sent over. Seems like a open issue is out there. Commented Jan 18, 2018 at 14:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.