简体   繁体   中英

MongoDB Java driver: autoConnectRetry

Our current connection configuration looks like this:

MongoClientOptions.builder()
    .autoConnectRetry(true).maxAutoConnectRetryTime(1200000)
    .socketTimeout(30000).connectTimeout(15000).build();
     // SocketTimeout: 30s, ConnectionTimeout 15s, ReconnectRetry: 20min

autoConnectRetry and maxAutoConnectRetryTime are deprecated in the current version ( source code ) and will be removed: "There is no replacement for this method. Use the connectTimeout property to control connection timeout."

I thought retries and connection timeouts were two different things. Does anyone know why this was changed and what (internal) implications this has?

There was a lot of confusion about the meaning of autoConnectRetry. Most people think it means that, if an operation failed due to an IOException, the driver would retry the operation until maxAutoConnectRetryTime elapsed. But that is not the case.

All it means is that, on calls to Socket.connect(), the driver retries a failed attempt to connect until maxAutoConnectRetryTime elapsed. But this is exactly what connectTimeout is for. The only additional capability of autoConnectRetry is so that you can specify a longer connect timeout than is allowed by the underlying operating system (which typically enforces a max connect timeout that caps the value that the user specifies).

Due to this confusion, the lack of value of the feature, and the fact that none of the other MongoDB drivers support this feature, we decided to deprecate it (and remove it in the next major release).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM