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

getMore with awaitData does not awaitData on first empty batch

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Querying
    • None
    • ALL
    • Hide

      var rs = ReplSetTest({nodes: 1});
      rs.startSet();
      rs.initiate();
      var db = rs.nodes[0].getDB("local");
       
      var findCmdRes = db.runCommand({
      	find: "oplog.rs",
      	tailable: true,
      	awaitData: true,
      	maxTimeMS: 60000
      });
      print("Time after find: " + (new Date()).toString());
      printjson(findCmdRes);
       
      var getMoreRes = db.runCommand({getMore: findCmdRes.cursor.id, collection: "oplog.rs", maxTimeMS: 5000});
      print("Time after first getMore: " + (new Date()).toString());
      printjson(getMoreRes);
       
      getMoreRes = db.runCommand({getMore: findCmdRes.cursor.id, collection: "oplog.rs", maxTimeMS: 5000});
      print("Time after second getMore: " + (new Date()).toString());
      printjson(getMoreRes);
       
      getMoreRes = db.runCommand({getMore: findCmdRes.cursor.id, collection: "oplog.rs", maxTimeMS: 5000});
      print("Time after third getMore: " + (new Date()).toString());
      printjson(getMoreRes);
      

      Output

      Time after find: Fri Jun 10 2016 13:23:23 GMT-0400 (EDT)
      {
          "waitedMS" : NumberLong(0),
          "cursor" : {
              "firstBatch" : [
                  {
                      "ts" : Timestamp(1465579402, 1),
                      "h" : NumberLong("9006574743864708869"),
                      "v" : 2,
                      "op" : "n",
                      "ns" : "",
                      "o" : {
                          "msg" : "initiating set"
                      }
                  },
                  {
                      "ts" : Timestamp(1465579403, 1),
                      "t" : NumberLong(1),
                      "h" : NumberLong("3841223321967630675"),
                      "v" : 2,
                      "op" : "n",
                      "ns" : "",
                      "o" : {
                          "msg" : "new primary"
                      }
                  }
              ],
              "id" : NumberLong("28093652894"),
              "ns" : "local.oplog.rs"
          },
          "ok" : 1
      }
      Time after first getMore: Fri Jun 10 2016 13:23:23 GMT-0400 (EDT)
      {
          "cursor" : {
              "nextBatch" : [ ],
              "id" : NumberLong("28093652894"),
              "ns" : "local.oplog.rs"
          },
          "ok" : 1
      }
      Time after second getMore: Fri Jun 10 2016 13:23:28 GMT-0400 (EDT)
      {
          "cursor" : {
              "nextBatch" : [ ],
              "id" : NumberLong("28093652894"),
              "ns" : "local.oplog.rs"
          },
          "ok" : 1
      }
      Time after third getMore: Fri Jun 10 2016 13:23:33 GMT-0400 (EDT)
      {
          "cursor" : {
              "nextBatch" : [ ],
              "id" : NumberLong("28093652894"),
              "ns" : "local.oplog.rs"
          },
          "ok" : 1
      }
      

      Show
      var rs = ReplSetTest({nodes: 1}); rs.startSet(); rs.initiate(); var db = rs.nodes[0].getDB( "local" );   var findCmdRes = db.runCommand({ find: "oplog.rs" , tailable: true , awaitData: true , maxTimeMS: 60000 }); print( "Time after find: " + ( new Date()).toString()); printjson(findCmdRes);   var getMoreRes = db.runCommand({getMore: findCmdRes.cursor.id, collection: "oplog.rs" , maxTimeMS: 5000}); print( "Time after first getMore: " + ( new Date()).toString()); printjson(getMoreRes);   getMoreRes = db.runCommand({getMore: findCmdRes.cursor.id, collection: "oplog.rs" , maxTimeMS: 5000}); print( "Time after second getMore: " + ( new Date()).toString()); printjson(getMoreRes);   getMoreRes = db.runCommand({getMore: findCmdRes.cursor.id, collection: "oplog.rs" , maxTimeMS: 5000}); print( "Time after third getMore: " + ( new Date()).toString()); printjson(getMoreRes); Output Time after find: Fri Jun 10 2016 13:23:23 GMT-0400 (EDT) { "waitedMS" : NumberLong(0), "cursor" : { "firstBatch" : [ { "ts" : Timestamp(1465579402, 1), "h" : NumberLong("9006574743864708869"), "v" : 2, "op" : "n", "ns" : "", "o" : { "msg" : "initiating set" } }, { "ts" : Timestamp(1465579403, 1), "t" : NumberLong(1), "h" : NumberLong("3841223321967630675"), "v" : 2, "op" : "n", "ns" : "", "o" : { "msg" : "new primary" } } ], "id" : NumberLong("28093652894"), "ns" : "local.oplog.rs" }, "ok" : 1 } Time after first getMore: Fri Jun 10 2016 13:23:23 GMT-0400 (EDT) { "cursor" : { "nextBatch" : [ ], "id" : NumberLong("28093652894"), "ns" : "local.oplog.rs" }, "ok" : 1 } Time after second getMore: Fri Jun 10 2016 13:23:28 GMT-0400 (EDT) { "cursor" : { "nextBatch" : [ ], "id" : NumberLong("28093652894"), "ns" : "local.oplog.rs" }, "ok" : 1 } Time after third getMore: Fri Jun 10 2016 13:23:33 GMT-0400 (EDT) { "cursor" : { "nextBatch" : [ ], "id" : NumberLong("28093652894"), "ns" : "local.oplog.rs" }, "ok" : 1 }
    • Query 16 (06/24/16)

    Description

      a getMore with awaitData=true is supposed to block until maxTimeMS runs out when there is no data for it to return. On the first getMore in a series of empty getMores, the getMore will return immediately with no new data. Subsequent getMores will wait maxTimeMS before returning as they are supposed to.

      Attachments

        Activity

          People

            max.hirschhorn@mongodb.com Max Hirschhorn
            judah.schvimer@mongodb.com Judah Schvimer
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: