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

mongos does not guarantee ordering between getmores and unchecked write operations run on the same connection

    XMLWordPrintableJSON

Details

    • Cluster Scalability

    Description

      For example:

      c = t.find( {$or:[

      {a:2}

      ,

      {b:3}

      ,

      {c:4}

      ]} ).batchSize( 2 );
      c.next();
      t.remove(

      {b:3}

      );
      assert.eq.automsg( "3", c.itcount() );

      The first getmore, caused by itcount(), may happen either before or after the remove if mediated by mongos. The following workaround is currently needed:

      c = t.find( {$or:[

      {a:2}

      ,

      {b:3}

      ,

      {c:4}

      ]} ).batchSize( 2 );
      c.next();
      t.remove(

      {b:3}

      );
      db.getLastError();
      assert.eq.automsg( "3", c.itcount() );

      Here is an example logging expected behavior from the above script:

      m30001| Mon Apr 25 23:31:42 [conn4] query test.jstests_or5 ntoreturn:2 reslen:102 nreturned:2 0ms
      m30001| Mon Apr 25 23:31:42 [conn4] remove test.jstests_or5 query:

      { b: 3.0 }

      0ms
      m30001| Mon Apr 25 23:31:42 [conn8] getmore test.jstests_or5 cid:4546250274389464629 ntoreturn:2 getMore: { $or: [

      { a: 2.0 }

      ,

      { b: 3.0 }

      ,

      { c: 4.0 }

      ] } bytes:86 nreturned:2 0ms
      m30001| Mon Apr 25 23:31:42 [conn8] getmore test.jstests_or5 cid:4546250274389464629 ntoreturn:2 getMore: { $or: [

      { a: 2.0 }

      ,

      { b: 3.0 }

      ,

      { c: 4.0 }

      ] } bytes:20 nreturned:0 0ms

      Here is an example of unexpected behavior that sometimes occurs:

      m30001| Mon Apr 25 23:11:51 [conn4] query test.jstests_or5 ntoreturn:2 reslen:102 nreturned:2 0ms
      m30001| Mon Apr 25 23:11:51 [conn8] getmore test.jstests_or5 cid:5426795093500586304 ntoreturn:2 getMore: { $or: [

      { a: 2.0 }

      ,

      { b: 3.0 }

      ,

      { c: 4.0 }

      ] } bytes:86 nreturned:2 0ms
      m30001| Mon Apr 25 23:11:51 [conn8] getmore test.jstests_or5 cid:5426795093500586304 ntoreturn:2 getMore: { $or: [

      { a: 2.0 }

      ,

      { b: 3.0 }

      ,

      { c: 4.0 }

      ] } bytes:86 nreturned:2 0ms
      m30001| Mon Apr 25 23:11:51 [conn8] getmore test.jstests_or5 cid:5426795093500586304 ntoreturn:2 getMore: { $or: [

      { a: 2.0 }

      ,

      { b: 3.0 }

      ,

      { c: 4.0 }

      ] } bytes:20 nreturned:0 0ms
      m30001| Mon Apr 25 23:11:51 [conn4] remove test.jstests_or5 query:

      { b: 3.0 }

      0ms

      As far as I know there is a single connection from mongo to mongos in these examples, but there seem to be two connections from mongos to mongod and this causes the unexpected operation ordering.

      Attachments

        Activity

          People

            backlog-server-cluster-scalability Backlog - Cluster Scalability
            aaron Aaron Staple
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: