Open achimgrimm opened 2 years ago
We had the exact same requirement and achieved it by setting a longer timeout for a profile called cassandra-migration
in the application.conf file (see https://docs.datastax.com/en/developer/java-driver/4.0/manual/core/configuration/). It looks like this
`datastax-java-driver {
profiles { schema-migration { basic.request.timeout = 60 seconds } } ... }`
The profile can then set on the DataStax Database class using setExecutionProfileName
.
Our code for this looks like this
`log.info("Starting schema migration for keyspace[{}]", keyspaceName);
Keyspace keyspace = new Keyspace(keyspaceName);
try (Database database = new Database(cqlSessionSupplier.get(), keyspace)
.setExecutionProfileName("schema-migration")
) {
new MigrationTask(database, createMigrationRepository(), true).migrate();
}
log.info("Finished schema migration for keyspace[{}]", keyspaceName);`
Thanks @dnsbtchr for answering this. I will create a FAQ section in the README where I put this.
@achimgrimm based on your reaction I assume this works for you :)
Hi, I did not give it a try, as I was waiting for some more reaction. The solution will probably work fine for my use case. But I think, adding the timeout (or maybe an optional profile) as a config would make it way easier to integrate into spring boot.
We were able to resolve this using profiles as mentioned above.
However there is still one case where the execution profile is not always used. When you create a new instance of the 'Database' object, it will attempt to create the 'schema_migration' and 'schema_migration_leader' tables.
Is it possible to allow the execution profile name to be passed in on construction or refactor so the table creation does not happen in the constructor?
Edit: I created a pull request here: https://github.com/patka/cassandra-migration/pull/62
As of 2.5.0_v4 the execution profile can now be configured via spring: https://github.com/patka/cassandra-migration/blob/master_v4/cassandra-migration-spring-boot-starter/src/main/java/org/cognitor/cassandra/migration/spring/CassandraMigrationConfigurationProperties.java#L128-L144
I like to increase the timeouts for the migration tasks for my spring boot app. The default timeout for my app is set to 2 seconds. I don't want to change that, as it will change the application performance.
But for the actual migration during startup, I don't mind a bigger timeout. So it would be great to configure that specifically so that the startup does not fails.
Log message from the spring boot start: