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

Cached chunk version is not updated on mongod when useClusterClientCursor=false

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • Querying, Sharding
    • None
    • Fully Compatible
    • ALL
    • Hide

      run this via resmoke or in mongo shell:

      var st = new ShardingTest({ shards: 2, mongos: 4 });
      st.stopBalancer();
       
      var testDB_s0 = st.s.getDB('test');
      testDB_s0.adminCommand({ enableSharding: 'test' });
      testDB_s0.adminCommand({ movePrimary: 'test', to: 'shard0001' });
      testDB_s0.adminCommand({ shardCollection: 'test.user', key: { x: 1 }});
       
      var checkShardMajorVersion = function(conn, expectedVersion) {
          var shardVersionInfo = conn.adminCommand({ getShardVersion: 'test.user' });
          assert.eq(expectedVersion, shardVersionInfo.global.getTime());
      };
       
      ///////////////////////////////////////////////////////
      // Test shard with empty chunk
       
      // shard0: 0|0|a
      // shard1: 1|0|a, [-inf, inf)
      // mongos0: 1|0|a
       
      var testDB_s1 = st.s1.getDB('test');
      assert.writeOK(testDB_s1.user.insert({ x: 1 }));
      assert.commandWorked(testDB_s1.adminCommand({ moveChunk: 'test.user',
                                                    find: { x: 0 },
                                                    to: 'shard0000' }));
       
      // Official config:
      // shard0: 2|0|a, [-inf, inf)
      // shard1: 0|0|a
      //
      // Shard metadata:
      // shard0: 0|0|a
      // shard1: 0|0|a
      // mongos0: 1|0|a
       
      // Set mongos2 to version 2|0|a
      var testDB_s2 = st.s2.getDB('test');
      assert.neq(null, testDB_s2.user.findOne({ x: 1 }));
       
      ///////////////////////////////////////////////////////
      // Test 2 shards with 1 chunk
      // mongos versions: s0: 0|0|0, s2, s3: 2|0|a
       
      testDB_s1.user.drop();
      testDB_s1.adminCommand({ shardCollection: 'test.user', key: { x: 1 }});
      testDB_s1.adminCommand({ split: 'test.user', middle: { x: 0 }});
       
      // shard0: 0|0|b,
      // shard1: 1|1|b, [-inf, 0), [0, inf)
       
      testDB_s1.user.insert({ x: 1 });
      testDB_s1.user.insert({ x: -11 });
      assert.commandWorked(testDB_s1.adminCommand({ moveChunk: 'test.user',
                                                    find: { x: -1 },
                                                    to: 'shard0000' }));
       
      // Official config:
      // shard0: 2|0|b, [-inf, 0)
      // shard1: 2|1|b, [0, inf)
      //
      // Shard metadata:
      // shard0: 0|0|b
      // shard1: 2|1|b
      //
      // mongos2: 2|0|a
       
      checkShardMajorVersion(st.d0, 0);
      checkShardMajorVersion(st.d1, 2);
       
      // mongos2 still thinks that { x: 1 } belong to shard0000, but should be able to
      // refresh it's metadata correctly.
      assert.neq(null, testDB_s2.user.findOne({ x: 1 }));
       
      checkShardMajorVersion(st.d0, 2);
      st.stop();
      

      the test.user version on st.d0 (shard0) should be 2 but with useClusterClientCursor=false its 0

      However, if the code after

       // Set mongos2 to version 2|0|a 

      is not executed the test.user version is 0 for both code paths.

      Show
      run this via resmoke or in mongo shell: var st = new ShardingTest({ shards: 2, mongos: 4 }); st.stopBalancer();   var testDB_s0 = st.s.getDB('test'); testDB_s0.adminCommand({ enableSharding: 'test' }); testDB_s0.adminCommand({ movePrimary: 'test', to: 'shard0001' }); testDB_s0.adminCommand({ shardCollection: 'test.user', key: { x: 1 }});   var checkShardMajorVersion = function(conn, expectedVersion) { var shardVersionInfo = conn.adminCommand({ getShardVersion: 'test.user' }); assert.eq(expectedVersion, shardVersionInfo.global.getTime()); };   /////////////////////////////////////////////////////// // Test shard with empty chunk   // shard0: 0|0|a // shard1: 1|0|a, [-inf, inf) // mongos0: 1|0|a   var testDB_s1 = st.s1.getDB('test'); assert.writeOK(testDB_s1.user.insert({ x: 1 })); assert.commandWorked(testDB_s1.adminCommand({ moveChunk: 'test.user', find: { x: 0 }, to: 'shard0000' }));   // Official config: // shard0: 2|0|a, [-inf, inf) // shard1: 0|0|a // // Shard metadata: // shard0: 0|0|a // shard1: 0|0|a // mongos0: 1|0|a   // Set mongos2 to version 2|0|a var testDB_s2 = st.s2.getDB('test'); assert.neq(null, testDB_s2.user.findOne({ x: 1 }));   /////////////////////////////////////////////////////// // Test 2 shards with 1 chunk // mongos versions: s0: 0|0|0, s2, s3: 2|0|a   testDB_s1.user.drop(); testDB_s1.adminCommand({ shardCollection: 'test.user', key: { x: 1 }}); testDB_s1.adminCommand({ split: 'test.user', middle: { x: 0 }});   // shard0: 0|0|b, // shard1: 1|1|b, [-inf, 0), [0, inf)   testDB_s1.user.insert({ x: 1 }); testDB_s1.user.insert({ x: -11 }); assert.commandWorked(testDB_s1.adminCommand({ moveChunk: 'test.user', find: { x: -1 }, to: 'shard0000' }));   // Official config: // shard0: 2|0|b, [-inf, 0) // shard1: 2|1|b, [0, inf) // // Shard metadata: // shard0: 0|0|b // shard1: 2|1|b // // mongos2: 2|0|a   checkShardMajorVersion(st.d0, 0); checkShardMajorVersion(st.d1, 2);   // mongos2 still thinks that { x: 1 } belong to shard0000, but should be able to // refresh it's metadata correctly. assert.neq(null, testDB_s2.user.findOne({ x: 1 }));   checkShardMajorVersion(st.d0, 2); st.stop(); the test.user version on st.d0 (shard0) should be 2 but with useClusterClientCursor=false its 0 However, if the code after // Set mongos2 to version 2|0|a is not executed the test.user version is 0 for both code paths.
    • Sharding A (10/09/15)

    Description

      mongos with useClusterClientCursor=true and legacy show different behavior.

      Attachments

        Activity

          People

            misha.tyulenev@mongodb.com Misha Tyulenev
            misha.tyulenev@mongodb.com Misha Tyulenev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: