Skip to content

Commit 23017fb

Browse files
committed
DRIVER-201: revert LBP query plan to use original contact points
Before-init query plan now uses getContactPoints() (original unresolved hostname nodes) instead of getResolvedContactPoints(). The DNS expansion to all IPs happens at the ChannelFactory level (PR scylladb#890), so expanding here was redundant and broke should_connect_with_mocked_hostname by replacing hostname endpoints with resolved-IP endpoints. Also remove the should_connect_when_first_dns_entry_is_non_responsive integration test from this PR; it belongs in PR scylladb#890 where ChannelFactory expansion actually enables it to pass.
1 parent d582a53 commit 23017fb

3 files changed

Lines changed: 1 addition & 45 deletions

File tree

core/src/main/java/com/datastax/oss/driver/internal/core/metadata/LoadBalancingPolicyWrapper.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,7 @@ public Queue<Node> newQueryPlan(
147147
switch (stateRef.get()) {
148148
case BEFORE_INIT:
149149
case DURING_INIT:
150-
// The contact points are not stored in the metadata yet; use the expanded list so that
151-
// all DNS-mapped IPs are tried (not just the first one per hostname).
152-
List<Node> nodes = new ArrayList<>(context.getMetadataManager().getResolvedContactPoints());
150+
List<Node> nodes = new ArrayList<>(context.getMetadataManager().getContactPoints());
153151
Collections.shuffle(nodes);
154152
return new ConcurrentLinkedQueue<>(nodes);
155153
case RUNNING:

core/src/test/java/com/datastax/oss/driver/internal/core/metadata/LoadBalancingPolicyWrapperTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ public void setup() {
101101
when(metadataManager.getMetadata()).thenReturn(metadata);
102102
when(metadata.getNodes()).thenReturn(allNodes);
103103
when(metadataManager.getContactPoints()).thenReturn(contactPoints);
104-
when(metadataManager.getResolvedContactPoints())
105-
.thenReturn(ImmutableList.copyOf(contactPoints));
106104
when(context.getMetadataManager()).thenReturn(metadataManager);
107105

108106
when(context.getConfig()).thenReturn(config);

integration-tests/src/test/java/com/datastax/oss/driver/core/resolver/MockResolverIT.java

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -201,46 +201,6 @@ public void run_replace_test_20_times() {
201201
}
202202
}
203203

204-
/**
205-
* Verifies that the driver can connect to a cluster when the first DNS entry for the contact
206-
* point hostname resolves to a non-responsive IP address (DRIVER-201).
207-
*
208-
* <p>Contact points are always kept as unresolved hostnames and expanded to all their DNS IPs at
209-
* connection time. When the first IP is unreachable the driver tries the remaining ones, so the
210-
* session opens successfully even if the first DNS entry is non-responsive.
211-
*/
212-
@Test
213-
public void should_connect_when_first_dns_entry_is_non_responsive() {
214-
// Use a 2-node cluster on 127.0.1.x. Node 11 (127.0.1.11) does not exist and is therefore
215-
// non-responsive; nodes 1 and 2 are real.
216-
try (CcmBridge ccmBridge = CcmBridge.builder().withNodes(2).withIpPrefix("127.0.1.").build()) {
217-
MultimapHostResolverProvider.removeResolverEntries("test.cluster.fake");
218-
// First entry intentionally points to a non-existent/non-responsive address.
219-
MultimapHostResolverProvider.addResolverEntry("test.cluster.fake", "127.0.1.11");
220-
MultimapHostResolverProvider.addResolverEntry(
221-
"test.cluster.fake", ccmBridge.getNodeIpAddress(1));
222-
MultimapHostResolverProvider.addResolverEntry(
223-
"test.cluster.fake", ccmBridge.getNodeIpAddress(2));
224-
ccmBridge.create();
225-
ccmBridge.start();
226-
227-
DriverConfigLoader loader =
228-
new DefaultProgrammaticDriverConfigLoaderBuilder()
229-
.withBoolean(TypedDriverOption.RECONNECT_ON_INIT.getRawOption(), false)
230-
.withStringList(
231-
TypedDriverOption.CONTACT_POINTS.getRawOption(),
232-
Collections.singletonList("test.cluster.fake:9042"))
233-
.build();
234-
235-
// The session must open successfully despite the first DNS entry being unreachable.
236-
try (CqlSession session = new CqlSessionBuilder().withConfigLoader(loader).build()) {
237-
ResultSet rs = session.execute("select * from system.local where key='local'");
238-
assertThat(rs.one()).isNotNull();
239-
waitForAllNodesUp(session, 2);
240-
}
241-
}
242-
}
243-
244204
// This is too long to run during CI, but is useful for manual investigations.
245205
@SuppressWarnings("unused")
246206
public void cannot_reconnect_with_resolved_socket() {

0 commit comments

Comments
 (0)