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

shardedcluster.py does not wait correctly on shards initialization

    • Fully Compatible
    • ALL
    • v5.0, v4.9, v4.4
    • Sharding 2020-09-07, Sharding 2021-01-11, Sharding 2021-01-25, Sharding 2021-02-22, Sharding 2021-03-08, Sharding 2021-03-22
    • 129

      This test

      var t = db.count_test;
      t.drop();
      assert.eq(0, t.find().count());
      

      will fail if run as

      resmoke.py --suites causally_consistent_jscore_passthrough test.js 
      

      when

      shard_options:
            voting_secondaries: false
      

      This happens because the https://github.com/mongodb/mongo/blob/r3.7.5/buildscripts/resmokelib/testing/fixtures/replicaset.py#L214 does not wait for sharding initialization to be completed.
      Now it waits for isMaster command to return. Instead it should wait for getShardVersion command to return.

      The error usually manifests as the following output in a log:

      [js_test:test] 2018-04-20T14:53:45.437-0400 2018-04-20T14:53:45.436-0400 E QUERY    [js] Error: count failed: {
      [js_test:test] 2018-04-20T14:53:45.437-0400 	"shards" : {
      [js_test:test] 2018-04-20T14:53:45.437-0400 
      [js_test:test] 2018-04-20T14:53:45.437-0400 	},
      [js_test:test] 2018-04-20T14:53:45.437-0400 	"ok" : 0,
      [ShardedClusterFixture:job0:shard0:secondary] 2018-04-20T14:53:45.435-0400 I COMMAND  [conn16] command test.$cmd appName: "MongoDB Shell" command: count { count: "count11", query: {}, readConcern: { afterClusterTime: Timestamp(1524250425, 13) }, shardVersion: [ Timestamp(0, 0), ObjectId('000000000000000000000000') ], databaseVersion: { uuid: UUID("ca2ebfda-a474-45a6-be00-e34b1fd3b8d3"), lastMod: 1 }, allowImplicitCollectionCreation: false, $readPreference: { mode: "secondary" }, $clusterTime: { clusterTime: Timestamp(1524250425, 13), signature: { hash: BinData(0, 2F88278346C7769F7FDC385B699AF171BA769BF4), keyId: 6546605683339427852 } }, $client: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "0.0.0" }, os: { type: "Linux", name: "LinuxMint", architecture: "x86_64", version: "18.1" }, mongos: { host: "greyparrot:20003", client: "127.0.0.1:40580", version: "0.0.0" } }, $configServerState: { opTime: { ts: Timestamp(1524250425, 13), t: 1 } }, $db: "test" } numYields:0 ok:0 errMsg:"Cannot accept sharding commands if sharding state has not been initialized with a shardIdentity document" errName:ShardingStateNotInitialized errCode:203 reslen:332 locks:{} protocol:op_msg 0ms
      [js_test:test] 2018-04-20T14:53:45.437-0400 	"errmsg" : "failed on: shard-rs0 :: caused by :: Cannot accept sharding commands if sharding state has not been initialized with a shardIdentity document",
      [js_test:test] 2018-04-20T14:53:45.437-0400 	"code" : 203,
      [js_test:test] 2018-04-20T14:53:45.438-0400 	"codeName" : "ShardingStateNotInitialized",
      [js_test:test] 2018-04-20T14:53:45.438-0400 	"$clusterTime" : {
      [js_test:test] 2018-04-20T14:53:45.438-0400 		"clusterTime" : Timestamp(1524250425, 13),
      [ShardedClusterFixture:job0:mongos] 2018-04-20T14:53:45.438-0400 I NETWORK  [conn13] end connection 127.0.0.1:40580 (0 connections now open)
      [js_test:test] 2018-04-20T14:53:45.438-0400 		"signature" : {
      [js_test:test] 2018-04-20T14:53:45.438-0400 			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      [js_test:test] 2018-04-20T14:53:45.438-0400 			"keyId" : NumberLong(0)
      [js_test:test] 2018-04-20T14:53:45.438-0400 		}
      [js_test:test] 2018-04-20T14:53:45.439-0400 	},
      [js_test:test] 2018-04-20T14:53:45.439-0400 	"operationTime" : Timestamp(1524250420, 3)
      [js_test:test] 2018-04-20T14:53:45.439-0400 } :
      [js_test:test] 2018-04-20T14:53:45.439-0400 _getErrorWithCode@src/mongo/shell/utils.js:25:13
      [js_test:test] 2018-04-20T14:53:45.439-0400 DBQuery.prototype.count@src/mongo/shell/query.js:375:11
      [js_test:test] 2018-04-20T14:53:45.439-0400 @test.js:10:14
      [js_test:test] 2018-04-20T14:53:45.439-0400 failed to load: test.js
      

            Assignee:
            kshitij.gupta@mongodb.com Kshitij Gupta
            Reporter:
            misha.tyulenev@mongodb.com Misha Tyulenev
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: