Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-1619

mongosh should warn when redacting command options

    • Type: Icon: Task Task
    • Resolution: Duplicate
    • Priority: Icon: Trivial - P5 Trivial - P5
    • No version
    • Affects Version/s: None
    • Component/s: None
    • Not Needed

      db.mycoll.createIndex({a:1}, {expireAfterSeconds:100});
      
      db.runCommand({insert:"mycoll", documents:[{a: new Date()}]});
      {
        n: 1,
        electionId: ObjectId("7fffffff0000000000000002"),
        opTime: { ts: Timestamp({ t: 1697567560, i: 1 }), t: Long("2") },
        ok: 1,
        '$clusterTime': {
          clusterTime: Timestamp({ t: 1697567560, i: 1 }),
          signature: {
            hash: Binary(Buffer.from("171844c93c4de1a44f50a4ff32d591bfb90f1428", "hex"), 0),
            keyId: Long("7290770490346438661")
          }
        },
        operationTime: Timestamp({ t: 1697567560, i: 1 })
      }
      
      // Wait a few minutes …
      
      // mongosh’s find() command returns nothing:
      db.mycoll.find({}, null, {readConcern:{level:"snapshot", atClusterTime: Timestamp({ t: 1697567560, i: 2 })}});
      
      // … but the server’s `find` command returns the expired document:
      db.runCommand({find: "mycoll", readConcern:{level:"snapshot", atClusterTime: Timestamp({ t: 1697567560, i: 1 })}});
      {
        cursor: {
          firstBatch: [
            {
              _id: ObjectId("652ed34800e1939439b41b7d"),
              a: ISODate("2023-10-17T18:32:40.160Z")
            }
          ],
          id: Long("0"),
          ns: 'test.mycoll',
          atClusterTime: Timestamp({ t: 1697567560, i: 1 })
        },
        ok: 1,
        '$clusterTime': {
          clusterTime: Timestamp({ t: 1697567800, i: 1 }),
          signature: {
            hash: Binary(Buffer.from("3bfdb41c158047adf591122381b46aa9e8c2e406", "hex"), 0),
            keyId: Long("7290770490346438661")
          }
        },
        operationTime: Timestamp({ t: 1697567800, i: 1 })
      }
      

      It appears that mongosh is quietly redacting the readConcern.atClusterTime from the request.

      When this happens, mongosh should show a warning like:

      WARN: Redacting unsupported option readConcern.atClusterTime

      Otherwise it’s quite confusing.

            Assignee:
            Unassigned Unassigned
            Reporter:
            felipe.gasper@mongodb.com Felipe Gasper
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: