In my Spring Boot 2.3.0.RELEASE, I use spring-data-cassandra 3.0.0.RELEASE.

I can't configure the init-query-timeout trough :

spring.data.cassandra.connection.init-query-timeout=2000ms The only way it works is to set directly :

datastax-java-driver.advanced.connection.init-query-timeout=2 seconds This is not compliant with the documentation :

https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html

See : https://jira.spring.io/browse/DATACASS-783

Comment From: wilkinsona

Thanks for the report. It's not clear from what you've described thus far why the property does not work for you. We have a test that verifies that it can be used to configure the timeout:

https://github.com/spring-projects/spring-boot/blob/ecc50d179d37e6a467b495eba509657d2918329f/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationTests.java#L132-L141

If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

Comment From: fabienmifsud

Hi Andy, Cassandra driver needs a duration in properties like : "2 seconds" or "10 miliseconds". I guess this is the issue here. I can fix it by a fork/PR if you need since I have a project to test on it.

Comment From: wilkinsona

@fabienmifsud I don't think the format required in Cassandra's properties file is relevant here. We are setting the timeout programatically:

https://github.com/spring-projects/spring-boot/blob/ecbc8ea2dfa308d6a2860c6490c80f36b64936cf/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java#L144-L145

It's set as an int which Cassandra treats as millis. This is confirmed by a modified version of the test that I linked to earlier:

@Test
void driverConfigLoaderCustomizeConnectionOptions() {
    this.contextRunner.withPropertyValues("spring.data.cassandra.connection.connect-timeout=200ms",
            "spring.data.cassandra.connection.init-query-timeout=10").run((context) -> {
                DriverExecutionProfile config = context.getBean(DriverConfigLoader.class).getInitialConfig()
                        .getDefaultProfile();
                assertThat(config.getDuration(DefaultDriverOption.CONNECTION_INIT_QUERY_TIMEOUT)).hasMillis(10);
                assertThat(config.getDuration(DefaultDriverOption.CONNECTION_CONNECT_TIMEOUT)).hasMillis(200);
            });
}

Thanks for the offer of a PR, but I'm not at that stage as I don't understand the problem that you've reported. We really need to be able to understand it before we can review any proposed fix. To that end, can you please provide a small sample that reproduces the problem?

Comment From: fabienmifsud

Here is the project I've used to test the issue : https://github.com/fabienmifsud/spring-cassandra-data-issue First commit is a working example, second commit is my failed example. I guess the use of a custom CassandraConfiguration is my root issue.

Comment From: wilkinsona

I guess the use of a custom CassandraConfiguration is my root issue.

Yes, that's right. If you start your application with --debug you can see that Spring Boot's auto-configuration for Cassandra has backed off:

   CassandraAutoConfiguration#cassandraSession:
      Did not match:
         - @ConditionalOnMissingBean (types: com.datastax.oss.driver.api.core.CqlSession; SearchStrategy: all) found beans of type 'com.datastax.oss.driver.api.core.CqlSession' session (OnBeanCondition)

   CassandraDataAutoConfiguration#cassandraConverter:
      Did not match:
         - @ConditionalOnMissingBean (types: org.springframework.data.cassandra.core.convert.CassandraConverter; SearchStrategy: all) found beans of type 'org.springframework.data.cassandra.core.convert.CassandraConverter' converter (OnBeanCondition)

   CassandraDataAutoConfiguration#cassandraMapping:
      Did not match:
         - @ConditionalOnMissingBean (types: org.springframework.data.cassandra.core.mapping.CassandraMappingContext; SearchStrategy: all) found beans of type 'org.springframework.data.cassandra.core.mapping.CassandraMappingContext' mappingContext (OnBeanCondition)

   CassandraDataAutoConfiguration#cassandraSessionFactory:
      Did not match:
         - @ConditionalOnMissingBean (types: org.springframework.data.cassandra.SessionFactory; SearchStrategy: all) found beans of type 'org.springframework.data.cassandra.SessionFactory' sessionFactory (OnBeanCondition)

   CassandraDataAutoConfiguration#cassandraTemplate:
      Did not match:
         - @ConditionalOnMissingBean (types: org.springframework.data.cassandra.core.CassandraOperations; SearchStrategy: all) found beans of type 'org.springframework.data.cassandra.core.CassandraOperations' cassandraTemplate (OnBeanCondition)

It has backed off because you have defined a number of Cassandra-related beans yourself. Your custom configuration isn't using the spring.data.cassandra.connection.init-query-timeout property so it isn't being applied. If you want to make use of Spring Boot's configuration properties, I would recommend deleting as much of your custom Cassandra configuration as possible.