title: MongoDB retryWrites=true is not working with version 3.6+
body: <p>I have read through <a href="https://docs.mongodb.com/manual/core/retryable-writes/" rel="nofollow noreferrer">https://docs.mongodb.com/manual/core/retryable-writes/</a> and setup the all the required properties to make it work, but no luck as of now.</p>
  
  <p>Have 3 members replica, and while program is running to insert records, I killing the primary, and while election happening for new primary the loop is happening in my code and those records are not retrying to write after new member is elected.</p>
  
  <h3>MongoDB Version local</h3>
  
  <pre><code>``
  mongo --version
  MongoDB shell version v3.6.6
  git version: 6405d65b1d6432e138b44c13085d0c2fe235d6bd
  OpenSSL version: OpenSSL 1.1.0h  27 Mar 2018
  allocator: system
  modules: enterprise 
  build environment:
      distarch: x86_64
      target_arch: x86_64
  ``
  </code></pre>
  
  <h3>Mongo java drivers</h3>
  
  <pre><code>``compile group: 'org.mongodb', name: 'mongodb-driver', version: '3.6.4'
  compile group: 'org.mongodb', name: 'mongodb-driver-core', version: '3.6.4'
  compile group: 'org.mongodb', name: 'bson', version: '3.6.4'``
  </code></pre>
  
  <h3>Mongo connection string</h3>
  
  <pre><code>``dbUri = "mongodb://localhost:28000,localhost:28001,localhost:28002/test?replicaSet=rs01&amp;retryWrites=true&amp;w=2";``
  </code></pre>
  
  <h3>connection creation using MongoClient</h3>
  
  <p><code>MongoClient mongoClient = new MongoClient(new MongoClientURI(dbUri));</code></p>
  
  <h3>insert is doing with insertOne as below</h3>
  
  <pre><code>``
  
  
  private static void insertData(MongoClient mongoClient) {
          MongoDatabase db = mongoClient.getDatabase("test");
          MongoCollection&lt;Document&gt; collection = db.getCollection("customer");
  //      collection.withWriteConcern(WriteConcern.W2);
  
          deleteOldDocumets(collection);
          int customerId = 0;
  
          while (customerId &lt; 1000) {
  
              ++customerId;
              try {
                  Document document = new Document();
                  document.put("name", "user" + customerId);
                  document.put("age", customerId);
                  collection.insertOne(document);
  
                  logger.info("Customer : " + customerId + "  Time is : "
                          + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS")));
                  Thread.sleep(10);
              } catch (Exception e) {
                  logger.info("Primary connection closed, starting election in 5 secs");
              }
          }
          mongoClient.close();
      }``
  
  ### DB master props ###
  
  ``MongoDB Enterprise rs01:PRIMARY&gt; db.isMaster();
  {
      "hosts" : [
          "localhost:28000",
          "localhost:28001",
          "localhost:28002"
      ],
      "setName" : "rs01",
      "setVersion" : 1,
      "ismaster" : true,
      "secondary" : false,
      "primary" : "localhost:28000",
      "me" : "localhost:28000",
      "electionId" : ObjectId("7fffffff0000000000000001"),
      "lastWrite" : {
          "opTime" : {
              "ts" : Timestamp(1540647424, 1),
              "t" : NumberLong(1)
          },
          "lastWriteDate" : ISODate("2018-10-27T13:37:04Z"),
          "majorityOpTime" : {
              "ts" : Timestamp(1540647424, 1),
              "t" : NumberLong(1)
          },
          "majorityWriteDate" : ISODate("2018-10-27T13:37:04Z")
      },
      "maxBsonObjectSize" : 16777216,
      "maxMessageSizeBytes" : 48000000,
      "maxWriteBatchSize" : 100000,
      "localTime" : ISODate("2018-10-27T13:37:10.713Z"),
      "logicalSessionTimeoutMinutes" : 30,
      "minWireVersion" : 0,
      "maxWireVersion" : 6,
      "readOnly" : false,
      "ok" : 1,
      "operationTime" : Timestamp(1540647424, 1),
      "$clusterTime" : {
          "clusterTime" : Timestamp(1540647424, 1),
          "signature" : {
              "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
              "keyId" : NumberLong(0)
          }
      }
  }
  ``
  </code></pre>
  
  <h3>Any clue is greatly appreciated.</h3>