Skip to content

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

Description

@dkropachev

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);
    }
  }

Migrated to Jira: DRIVER-201

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions