Skip to content

Commit 0e62d50

Browse files
committed
JVMCBC-1662 Preferred server group not honored in transactions
Motivation ---------- Honor the "preferredServerGroup" option for replica reads in transactions. Modifications ------------- Update NodeIndexCalculator to treat PREFERRED_SERVER_GROUP_OR_ALL_AVAILABLE the same as PREFERRED_SERVER_GROUP. The collaborator (ReplicaHelper) already handles falling back to all replicas if none are available in the preferred group. Change-Id: I051dcf72b06a4f345aa428327acb295a3bee43c6 Reviewed-on: https://review.couchbase.org/c/couchbase-jvm-clients/+/229517 Tested-by: Build Bot <[email protected]> Reviewed-by: Michael Reiche <[email protected]>
1 parent 4ad8734 commit 0e62d50

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

core-io/src/main/java/com/couchbase/client/core/service/kv/NodeIndexCalculator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
import java.nio.charset.StandardCharsets;
2727

28+
import static com.couchbase.client.core.api.kv.CoreReadPreference.PREFERRED_SERVER_GROUP;
29+
import static com.couchbase.client.core.api.kv.CoreReadPreference.PREFERRED_SERVER_GROUP_OR_ALL_AVAILABLE;
2830
import static com.couchbase.client.core.node.KeyValueLocator.partitionForKey;
2931

3032
@Stability.Internal
@@ -40,7 +42,7 @@ public NodeIndexCalculator(CoreReadPreference readPreference, CouchbaseBucketCon
4042
boolean canUseNode = true;
4143
PortInfo node = topology.portInfos().get(nodeIndex);
4244

43-
if (readPreference == CoreReadPreference.PREFERRED_SERVER_GROUP) {
45+
if (readPreference == PREFERRED_SERVER_GROUP || readPreference == PREFERRED_SERVER_GROUP_OR_ALL_AVAILABLE) {
4446
canUseNode = node.serverGroup() != null && node.serverGroup().equals(coreContext.environment().preferredServerGroup());
4547
}
4648

0 commit comments

Comments
 (0)