Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-89028

Support $let commands in setQuerySettings and removeQuerySettings

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.1.0-rc0, 8.0.0-rc2
    • Affects Version/s: None
    • Component/s: None
    • Query Execution
    • Fully Compatible
    • ALL
    • v8.0
    • QE 2024-04-15, QE 2024-04-29

      It was discovered as part of the newly introduced `implicit_query_settings_fallback` that trying to set query settings over commands involving variables fails with a "Use of undefined variable: <variable>" error. This happens when generating the query shape hash, and it's most probably due to how the blank expression context is constructed.

      Example error: Parsley Logs]

       uncaught exception: Error: command failed: {
           "ok" : 0,
           "errmsg" : "Invalid $addFields :: caused by :: Use of undefined variable: variable",
           "code" : 17276,
           "codeName" : "Location17276",
           "$clusterTime" : {
               "clusterTime" : Timestamp(1712334639, 18),
               "signature" : {
                   "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                   "keyId" : NumberLong(0)
               }
           },
           "operationTime" : Timestamp(1712334639, 18)
       } with original command request: {
           "setQuerySettings" : {
               "aggregate" : "command_let_variables",
               "$db" : "test",
               "cursor" : {         },
               "pipeline" : [
                   {
                       "$merge" : {
                           "into" : "command_let_variables_target",
                           "whenMatched" : [
                               {
                                   "$addFields" : {
                                       "var" : "$$variable"
                                   }
                               }
                           ]
                       }
                   }
               ],
               "let" : {
                   "variable" : "OUTER"
               },
               "lsid" : {
                   "id" : UUID("70376fd6-a2da-4d01-a7e9-a0780b412de9")
               },
               "$clusterTime" : {
                   "clusterTime" : Timestamp(1712334639, 18),
                   "signature" : {
                       "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                       "keyId" : NumberLong(0)
                   }
               }
           },
           "settings" : {
               "indexHints" : {
                   "ns" : {
                       "db" : "test",
                       "coll" : "command_let_variables"
                   },
                   "allowedIndexes" : [
                       "doesnotexist"
                   ]
               }
           },
           "lsid" : {
               "id" : UUID("70376fd6-a2da-4d01-a7e9-a0780b412de9")
           },
           "$clusterTime" : {
               "clusterTime" : Timestamp(1712334639, 18),
               "signature" : {
                   "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                   "keyId" : NumberLong(0)
               }
           }
       } on connection: connection to localhost:20000 : 

            Assignee:
            catalin.sumanaru@mongodb.com Catalin Sumanaru
            Reporter:
            catalin.sumanaru@mongodb.com Catalin Sumanaru
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: