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

enforceLegacyWriteConcern send all the requests to the primaries

    • ALL
    • v4.4
    • Sharding 2020-03-23
    • 16

      During ShardingTest initialization mongos tries to enforce LegacyWriteConcern by sending a GetLastError command on all the shards. The list of target to send the GLE to is constructed through getPrevHostOpTimes(). It is the case that the list contains two replica node of the same shard and that they have a different electionID. Thus two different GLE requests are generated for two different node with two different electionID.

      [js_test:gle_sharded_write] 2019-12-17T20:06:14.913+0000 s20775| 2019-12-17T20:06:14.911+0000 D3 SHARDING [conn8] enforcing write concern { getLastError: "settings", w: "majority", wtimeout: 30000.0, readConcern: {} } on ip-10-122-3-53:20772 at opTime Dec 17 20:06:14:8 with electionID 7fffffff0000000000000001
      [js_test:gle_sharded_write] 2019-12-17T20:06:14.913+0000 s20775| 2019-12-17T20:06:14.911+0000 D3 SHARDING [conn8] enforcing write concern { getLastError: "settings", w: "majority", wtimeout: 30000.0, readConcern: {} } on ip-10-122-3-53:20774 at opTime Jan  1 00:00:00:0 with electionID 000000000000000000000000
      

      And as you can see they have a different electionID.

      Then the generated requests are sent throw the MultiStatementTransactionRequestsSender, but since we specified ReadPreference::PrimaryOnly the two requests will be sent to the primary of the shards but with two different electionID.

      [js_test:gle_sharded_write] 2019-12-17T20:06:14.913+0000 s20775| 2019-12-17T20:06:14.911+0000 D3 ASIO     [conn8] startCommand: RemoteCommand 23 -- target:[ip-10-122-3-53:20772] db:config cmd:{ getLastError: "settings", w: "majority", wtimeout: 30000.0, readConcern: {}, wOpTime: { ts: Timestamp(1576613174, 8), t: 1 }, wElectionId: ObjectId('7fffffff0000000000000001') }
      
      [js_test:gle_sharded_write] 2019-12-17T20:06:14.913+0000 s20775| 2019-12-17T20:06:14.911+0000 D3 ASIO     [conn8] startCommand: RemoteCommand 24 -- target:[ip-10-122-3-53:20772] db:config cmd:{ getLastError: "settings", w: "majority", wtimeout: 30000.0, readConcern: {}, wOpTime: { ts: Timestamp(0, 0), t: -1 }, wElectionId: ObjectId('000000000000000000000000') }
      
      

      When the primary receives the requests, it will find out that the electionID doesn't match its own and will fail.

            Assignee:
            randolph@mongodb.com Randolph Tan
            Reporter:
            tommaso.tocci@mongodb.com Tommaso Tocci
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: