Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.x: can't connect to the cluster when first node is non-responsive #356

Open
dkropachev opened this issue Oct 7, 2024 · 0 comments
Open

Comments

@dkropachev
Copy link
Collaborator

Since netty bootstrap.connect uses only first address of unresolved InetSocketAddress 4.x does not even try to connect to other when it fails.

Consider following test:

  @Test
  public void cannot_connect_if_first_node_is_unavailable() {
    // Reproduce case when first two dns record contains nodes that are unresponsive
    // With RESOLVE_CONTACT_POINTS set to false
    DriverConfigLoader loader =
        new DefaultProgrammaticDriverConfigLoaderBuilder()
            .withBoolean(TypedDriverOption.RESOLVE_CONTACT_POINTS.getRawOption(), false)
            .withBoolean(TypedDriverOption.RECONNECT_ON_INIT.getRawOption(), true)
            .withStringList(
                TypedDriverOption.CONTACT_POINTS.getRawOption(),
                Collections.singletonList("test.cluster.fake:9042"))
            .build();

    CqlSessionBuilder builder = new CqlSessionBuilder().withConfigLoader(loader);
    CqlSession session;
    try (CcmBridge ccmBridge = CcmBridge.builder().withNodes(3).withIpPrefix("127.0.1.").build()) {
      MultimapHostResolverProvider.removeResolverEntries("test.cluster.fake");
      MultimapHostResolverProvider.addResolverEntry(
          "test.cluster.fake", ccmBridge.getNodeIpAddress(11));
      MultimapHostResolverProvider.addResolverEntry(
          "test.cluster.fake", ccmBridge.getNodeIpAddress(2));
      MultimapHostResolverProvider.addResolverEntry(
          "test.cluster.fake", ccmBridge.getNodeIpAddress(3));
      ccmBridge.create();
      ccmBridge.start();
      session = builder.build();
      SimpleStatement statement =
          new SimpleStatementBuilder("SELECT * FROM system.local")
              .setTimeout(Duration.ofSeconds(3))
              .build();
      session.execute(statement);
      ccmBridge.stop(2);
      session.execute(statement);
    }
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant