Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
ac1c120
JAVA-6035: Add backpressure flag to connection handshake (#1906)
nhachicha Mar 5, 2026
b33dca9
Add `MongoException.SYSTEM_OVERLOADED_ERROR_LABEL`/`RETRYABLE_ERROR_L…
stIncMale Mar 24, 2026
fa82369
JAVA-6055 Implement prose backpressure retryable writes tests (#1929)
stIncMale Apr 10, 2026
ffe5242
Add `maxAdaptiveRetries` API (#1944)
stIncMale Apr 20, 2026
44541fc
Add support for server selection's deprioritized servers (#1860)
vbabanin Apr 21, 2026
c380b2e
Implement prose backpressure tests (#1946)
stIncMale Apr 22, 2026
d083e1b
Add `enableOverloadRetargeting` API (#1943)
vbabanin Apr 23, 2026
bd888c9
Add handshake prose Test 9: backpressure: true in handshake documents…
nhachicha Apr 28, 2026
394f7b1
JAVA-5950 Update Transactions Convenient API with exponential backoff…
nhachicha May 1, 2026
0eb04a0
JAVA-6194 Add MongoSocksProxyException for CMAP backpressure labeling
nhachicha May 8, 2026
f2bcce5
Merge remote-tracking branch 'origin/backpressure' into nh/backpressu…
nhachicha May 16, 2026
28a074d
update submodule
nhachicha May 16, 2026
c2ca4fd
Address review nits in MongoSocksProxyException
nhachicha May 16, 2026
801127f
Close proxy socket on MongoSocksProxyException in SocksSocket.connect
nhachicha May 16, 2026
61a1c5e
Use getHostString in SocksSocket exception reporting path
nhachicha May 16, 2026
49e58f0
Fix socket leak in SOCKS5 initializer methods and DRY open()
nhachicha May 16, 2026
db26d92
Replace Thread.sleep(300) with input drain in SocksSocketTest
nhachicha May 16, 2026
fd39744
Use ephemeral closed port instead of port 1 in SocksSocketTest
nhachicha May 16, 2026
7416dd3
Use Java 8-compatible drain in SocksSocketTest mini-server
nhachicha May 18, 2026
4e3249b
Add Scala type alias for MongoSocksProxyException
nhachicha May 18, 2026
98483bb
Phase-aware MongoSocksProxyException handling in BackpressureErrorLab…
nhachicha May 18, 2026
78d6b01
Tag handshake-phase IOExceptions with the correct HandshakePhase
nhachicha May 18, 2026
dee79f0
Validate non-null HandshakePhase in MongoSocksProxyException
nhachicha May 18, 2026
b3da503
Align MongoSocksProxyException class-level Javadoc with phase-aware b…
nhachicha May 19, 2026
2c5be54
Broaden HandshakePhase enum Javadoc to cover I/O-failure path
nhachicha May 19, 2026
effa09a
Rename misleading eofDuring* tests to ioFailureDuring*
nhachicha May 19, 2026
095f524
Narrow tcpConnectFailure test to IOException, not Throwable
nhachicha May 19, 2026
582169c
Drive real EOF in ioFailureDuring* tests via half-close
nhachicha May 19, 2026
d7a9b15
Align constructor Javadoc with phase/replyCode semantics post round 2
nhachicha May 19, 2026
43e478c
Potential fix for pull request finding
nhachicha May 19, 2026
7971f9a
Widen outer catch in SocksSocket.connect to IOException
nhachicha May 19, 2026
27417eb
Drop redundant MongoSocksProxyException re-throw branches
nhachicha May 19, 2026
b2bb401
Drop redundant null-phase guard in BackpressureErrorLabeler
nhachicha May 19, 2026
2517b69
Backpressure-label SOCKS5 failures by mongod-attribution
nhachicha May 20, 2026
df8430c
Include proxy host:port in PROXY_TCP_CONNECT exception message
nhachicha May 20, 2026
0aafd71
Add SOCKS5/code context to CONNECT non-success reply message
nhachicha May 20, 2026
11a5866
Realign comments on the two outer catches in SocksSocket.connect
nhachicha May 20, 2026
4023a0b
Cleanups
nhachicha May 20, 2026
4cac195
Stop swallowing unexpected exceptions in connectWithMiniServer
nhachicha May 20, 2026
4a44d38
Document constructor parameter ordering convention
nhachicha May 20, 2026
4306d2e
Review feedback
nhachicha May 20, 2026
c5abbce
Fixing SOCKS5 failing prose tests
nhachicha May 20, 2026
9efad2b
Dropped the HandshakePhase enum
nhachicha May 21, 2026
a838766
PR feedback
nhachicha May 21, 2026
a1f0cb8
Wrapping IOException into MongoSocksProxyException to simplify logic …
nhachicha May 21, 2026
c188e24
Potential fix for pull request finding
nhachicha May 23, 2026
91d3d09
Copilot doc nits
nhachicha May 23, 2026
a239532
Update driver-core/src/test/unit/com/mongodb/internal/connection/Sock…
nhachicha May 23, 2026
9e09f96
Update driver-core/src/test/unit/com/mongodb/internal/connection/Sock…
nhachicha May 23, 2026
eb6a716
Update driver-core/src/test/unit/com/mongodb/internal/connection/Sock…
nhachicha May 23, 2026
196ddf1
Update driver-core/src/test/unit/com/mongodb/internal/connection/Sock…
nhachicha May 23, 2026
882a416
Review feedback
nhachicha May 23, 2026
2fe56ff
Copilot nit
nhachicha May 23, 2026
befdfff
Translate interrupt-flavored proxy-connect failures to MongoInterrupt…
nhachicha May 23, 2026
7975b3b
Merge remote-tracking branch 'origin/backpressure' into nh/backpressu…
nhachicha May 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

package com.mongodb.benchmark.benchmarks;

import org.bson.BsonArray;import org.bson.BsonDocument;
import org.bson.BsonArray;
import org.bson.BsonDocument;
import org.bson.RawBsonDocument;
import org.bson.codecs.BsonDocumentCodec;

Expand Down Expand Up @@ -52,4 +53,4 @@ public void setUp() throws IOException {
public int getBytesPerRun() {
return documentBytes.length * NUM_INTERNAL_ITERATIONS;
}
}
}
75 changes: 64 additions & 11 deletions driver-core/src/main/com/mongodb/ConnectionString.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.mongodb;

import com.mongodb.annotations.Alpha;
import com.mongodb.annotations.Beta;
import com.mongodb.annotations.Reason;
import com.mongodb.connection.ClusterSettings;
import com.mongodb.connection.ConnectionPoolSettings;
Expand Down Expand Up @@ -264,14 +265,20 @@
* <p>SRV configuration:</p>
* <ul>
* <li>{@code srvServiceName=string}: The SRV service name. See {@link ClusterSettings#getSrvServiceName()} for details.</li>
* <li>{@code srvMaxHosts=number}: The maximum number of hosts from the SRV record to connect to.</li>
* <li>{@code srvMaxHosts=n}: The maximum number of hosts from the SRV record to connect to.</li>
* </ul>
* <p>General configuration:</p>
* <ul>
* <li>{@code retryWrites=true|false}. If true the driver will retry supported write operations if they fail due to a network error.
* Defaults to true.</li>
* <li>{@code retryReads=true|false}. If true the driver will retry supported read operations if they fail due to a network error.
* Defaults to true.</li>
* <li>{@code retryWrites=true|false}: Whether attempts to execute write commands should be retried if they fail due to a retryable error.
* Defaults to true. See also {@code maxAdaptiveRetries}.</li>
* <li>{@code retryReads=true|false}: Whether attempts to execute read commands should be retried if they fail due to a retryable error.
* Defaults to true. See also {@code maxAdaptiveRetries}.</li>
* <li>{@code maxAdaptiveRetries=n}: This is {@linkplain Beta Beta API}.
* The maximum number of retry attempts when encountering a retryable overload error.
* See {@link MongoClientSettings.Builder#maxAdaptiveRetries(Integer)} for more information.</li>
* <li>{@code enableOverloadRetargeting=true|false}: This is {@linkplain Beta Beta API}.
* Whether to enable overload retargeting. Defaults to false.
* See {@link MongoClientSettings.Builder#enableOverloadRetargeting(boolean)} for more information.</li>
* <li>{@code uuidRepresentation=unspecified|standard|javaLegacy|csharpLegacy|pythonLegacy}. See
* {@link MongoClientSettings#getUuidRepresentation()} for documentation of semantics of this parameter. Defaults to "javaLegacy", but
* will change to "unspecified" in the next major release.</li>
Expand Down Expand Up @@ -308,6 +315,8 @@ public class ConnectionString {
private WriteConcern writeConcern;
private Boolean retryWrites;
private Boolean retryReads;
private Integer maxAdaptiveRetries;
private Boolean enableOverloadRetargeting;
private ReadConcern readConcern;

private Integer minConnectionPoolSize;
Expand Down Expand Up @@ -558,6 +567,8 @@ public ConnectionString(final String connectionString, @Nullable final DnsClient
GENERAL_OPTIONS_KEYS.add("servermonitoringmode");
GENERAL_OPTIONS_KEYS.add("retrywrites");
GENERAL_OPTIONS_KEYS.add("retryreads");
GENERAL_OPTIONS_KEYS.add("maxadaptiveretries");
GENERAL_OPTIONS_KEYS.add("enableoverloadretargeting");

GENERAL_OPTIONS_KEYS.add("appname");

Expand Down Expand Up @@ -706,6 +717,15 @@ private void translateOptions(final Map<String, List<String>> optionsMap) {
case "retryreads":
retryReads = parseBoolean(value, "retryreads");
break;
case "maxadaptiveretries":
maxAdaptiveRetries = parseInteger(value, "maxadaptiveretries");
if (maxAdaptiveRetries < 0) {
throw new IllegalArgumentException("maxAdaptiveRetries must be >= 0");
}
break;
case "enableoverloadretargeting":
enableOverloadRetargeting = parseBoolean(value, "enableoverloadretargeting");
break;
case "uuidrepresentation":
uuidRepresentation = createUuidRepresentation(value);
break;
Expand Down Expand Up @@ -1455,13 +1475,15 @@ public WriteConcern getWriteConcern() {
}

/**
* <p>Gets whether writes should be retried if they fail due to a network error</p>
*
* Gets whether attempts to execute write commands should be retried if they fail due to a retryable error.
* See {@link MongoClientSettings.Builder#retryWrites(boolean)} for more information.
* <p>
* The name of this method differs from others in this class so as not to conflict with the now removed
* getRetryWrites() method, which returned a primitive {@code boolean} value, and didn't allow callers to differentiate
* between a false value and an unset value.
*
* @return the retryWrites value, or null if unset
* @return the {@code retryWrites} value, or {@code null} if unset
* @see #getMaxAdaptiveRetries()
* @since 3.9
* @mongodb.server.release 3.6
*/
Expand All @@ -1471,9 +1493,11 @@ public Boolean getRetryWritesValue() {
}

/**
* <p>Gets whether reads should be retried if they fail due to a network error</p>
* Gets whether attempts to execute read commands should be retried if they fail due to a retryable error.
* See {@link MongoClientSettings.Builder#retryReads(boolean)} for more information.
*
* @return the retryWrites value
* @return the {@code retryReads} value, or {@code null} if unset
* @see #getMaxAdaptiveRetries()
* @since 3.11
* @mongodb.server.release 3.6
*/
Expand All @@ -1482,6 +1506,33 @@ public Boolean getRetryReads() {
return retryReads;
}

/**
* Gets the maximum number of retry attempts when encountering a retryable overload error.
* See {@link MongoClientSettings.Builder#maxAdaptiveRetries(Integer)} for more information.
*
* @return The {@code maxAdaptiveRetries} value, or {@code null} if unset.
* @since 5.7
*/
@Beta(Reason.CLIENT)
@Nullable
public Integer getMaxAdaptiveRetries() {
return maxAdaptiveRetries;
}

/**
* Gets whether overload retargeting is enabled.
* See {@link MongoClientSettings.Builder#enableOverloadRetargeting(boolean)} for more information.
*
* @return the enableOverloadRetargeting value, or null if not set
* @see MongoClientSettings.Builder#enableOverloadRetargeting(boolean)
* @since 5.7
*/
@Beta(Reason.CLIENT)
@Nullable
public Boolean getEnableOverloadRetargeting() {
return enableOverloadRetargeting;
}

/**
* Gets the minimum connection pool size specified in the connection string.
* @return the minimum connection pool size
Expand Down Expand Up @@ -1795,6 +1846,8 @@ public boolean equals(final Object o) {
&& Objects.equals(writeConcern, that.writeConcern)
&& Objects.equals(retryWrites, that.retryWrites)
&& Objects.equals(retryReads, that.retryReads)
&& Objects.equals(maxAdaptiveRetries, that.maxAdaptiveRetries)
&& Objects.equals(enableOverloadRetargeting, that.enableOverloadRetargeting)
&& Objects.equals(readConcern, that.readConcern)
&& Objects.equals(minConnectionPoolSize, that.minConnectionPoolSize)
&& Objects.equals(maxConnectionPoolSize, that.maxConnectionPoolSize)
Expand Down Expand Up @@ -1826,7 +1879,7 @@ public boolean equals(final Object o) {
@Override
public int hashCode() {
return Objects.hash(credential, isSrvProtocol, hosts, database, collection, directConnection, readPreference,
writeConcern, retryWrites, retryReads, readConcern, minConnectionPoolSize, maxConnectionPoolSize, maxWaitTime,
writeConcern, retryWrites, retryReads, maxAdaptiveRetries, enableOverloadRetargeting, readConcern, minConnectionPoolSize, maxConnectionPoolSize, maxWaitTime,
maxConnectionIdleTime, maxConnectionLifeTime, maxConnecting, connectTimeout, timeout, socketTimeout, sslEnabled,
sslInvalidHostnameAllowed, requiredReplicaSetName, serverSelectionTimeout, localThreshold, heartbeatFrequency,
serverMonitoringMode, applicationName, compressorList, uuidRepresentation, srvServiceName, srvMaxHosts, proxyHost,
Expand Down
Loading