title: Intermittent erro using mongo
body: <p>I'm having an error when using mongo with springboot, when trying to delete collections.</p>
  <p>This error occurs intermittently, sometimes it works and sometimes it doesn't.</p>
  <p>I'm usingo mongo gcp, version 4.4.13, with replica.</p>
  <p><strong>spring-boot version:</strong> 2.3.1</p>
  <p><strong>java version:</strong> 1.8</p>
  <p><strong>data.mongodb.uri:</strong> ${mongodb.host}t2b_sale?retryWrites=true&amp;w=majority</p>
  <pre><code>public void deleteLastVersion(String uuidOrganization, String uuidCampaign) {
      String collectionName = getName(uuidOrganization, uuidCampaign, false);
      mongoTemplate.dropCollection(collectionName);
      return;
  }
  </code></pre>
  <p>Log error:</p>
  <pre><code>2022-04-23 08:40:56.269  WARN 1 --- [ntainer#5-1-C-1] org.mongodb.driver.connection            : Got socket exception on connection [connectionId{localValue:10, serverValue:198632}] to thanos-shard-00-01.h07ky.mongodb.net:27017. All connections to thanos-shard-00-01.h07ky.mongodb.net:27017 will be closed.
  2022-04-23 08:40:56.270  INFO 1 --- [ntainer#5-1-C-1] org.mongodb.driver.connection            : Closed connection [connectionId{localValue:10, serverValue:198632}] to thanos-shard-00-01.h07ky.mongodb.net:27017 because there was a socket exception raised by this connection.
  org.springframework.data.mongodb.UncategorizedMongoDbException: Exception sending message; nested exception is com.mongodb.MongoSocketWriteException: Exception sending message
  2022-04-23 08:40:56.272  INFO 1 --- [ngodb.net:27017] org.mongodb.driver.cluster               : Discovered replica set primary thanos-shard-00-01.h07ky.mongodb.net:27017
  at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:133)
  at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2863)
  at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:568)
  at org.springframework.data.mongodb.core.MongoTemplate.doRemove(MongoTemplate.java:1712)
  at org.springframework.data.mongodb.core.MongoTemplate.remove(MongoTemplate.java:1678)
  at com.br.t2b.mercedeshitledengine.repository.BaseRepository.deleteLastVersion(BaseRepository.java:50)
  at com.br.t2b.mercedeshitledengine.repository.BaseRepository$$FastClassBySpringCGLIB$$6a40ae7c.invoke(&lt;generated&gt;)
  at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
  Caused by: com.mongodb.MongoSocketWriteException: Exception sending message
  at com.mongodb.internal.connection.InternalStreamConnection.translateWriteException(InternalStreamConnection.java:550)
  at com.mongodb.internal.connection.InternalStreamConnection.sendMessage(InternalStreamConnection.java:432)
  at com.mongodb.internal.connection.InternalStreamConnection.sendCommandMessage(InternalStreamConnection.java:272)
  at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:256)
  at com.mongodb.internal.connection.UsageTrackingInternalConnection.sendAndReceive(UsageTrackingInternalConnection.java:99)
  at com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection.sendAndReceive(DefaultConnectionPool.java:500)
  ... 40 more
  Caused by: java.net.SocketException: Broken pipe (Write failed)
  at java.net.SocketOutputStream.socketWrite0(Native Method)
  at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111)
  at java.net.SocketOutputStream.write(SocketOutputStream.java:155)
  at sun.security.ssl.OutputRecord.writeBuffer(OutputRecord.java:431)
  at sun.security.ssl.OutputRecord.write(OutputRecord.java:417)
  at sun.security.ssl.SSLSocketImpl.writeRecordInternal(SSLSocketImpl.java:879)
  at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:850)
  at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:123)
  at com.mongodb.internal.connection.SocketStream.write(SocketStream.java:99)
  at com.mongodb.internal.connection.InternalStreamConnection.sendMessage(InternalStreamConnection.java:429)
  ... 62 more
  </code></pre>