Skip to content

Add Lifecycle/CRaC support for Cassandra #44505

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

Closed
wants to merge 1 commit into from

Conversation

rvansa
Copy link

@rvansa rvansa commented Mar 3, 2025

Adds a bean that oversees Cassandra's CqlSession through Lifecycle; upon stop() all connections are forcefully terminated by marking all nodes as forced down, and unmarking these on start(). This might not be perfect if there's an ongoing topology change, but for a quiescent state it should be sufficient.

In order to support checkpoint onRefresh which does not stop beans that haven't been started (see disussion in spring-projects/spring-framework#34510 (comment) ) this registers a CRaC resource that will handle the checkpoint. After properly started the resource is removed left to be garbage-collected; potential interference between lifecycle and CRaC resource methods invocation is handled.

I have been trying to mimic HikariCheckpointRestoreLifecycle and I have added some tests similar to those in HikariDataSourceConfigurationTests; I would do the same for HikariCheckpointRestoreLifecycleTests but I am not sure where these should land, as the :spring-boot project does not depend on org.springframework.data:spring-data-cassandra. Please advise.

@rvansa
Copy link
Author

rvansa commented Mar 3, 2025

CC @sdeleuze

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 3, 2025
@rvansa rvansa changed the base branch from main to 3.4.x March 3, 2025 09:01
@wilkinsona
Copy link
Member

Thanks for the PR. If we accept the contribution, I would consider it to be a new feature so the base branch should be main rather than 3.4.x please.

@sdeleuze do you think this is worth supporting? I am sceptical that it is for the checkpoint-restore case but if it may benefit CDS as well then it may be worth the ongoing maintenance cost. Perhaps we need to wait for spring-projects/spring-framework#34510 to run its course before considering anything on the Boot side.

@wilkinsona wilkinsona added the status: waiting-for-internal-feedback An issue that needs input from a member or another Spring Team label Mar 4, 2025
@sdeleuze
Copy link
Contributor

sdeleuze commented Mar 5, 2025

@wilkinsona I am wondering the same. If such improvement can benefit to both CRaC and CDS, maybe it would be worth to consider. In order to have more information to decide, it would be interested to know if other databases have the same issue to estimate the scope of such effort if we want to unlock those use cases consistently. @christophstrobl I think you did some related analysis, if that's the case, could you please share which databases exposing directly lifecycle oriented beans are impacted?

@mp911de
Copy link
Member

mp911de commented Mar 6, 2025

Looking at the change, while it seems possible to restart driver connections, there's a lot of reliance on driver internals. Having lifecycle methods in the driver itself would create a more sustainable approach that doesn't require us to know the driver's internals.

@wilkinsona
Copy link
Member

Thanks, @mp911de. I agree.

@rvansa please open a Cassandra issue to see if they'll consider some lifecycle methods that would be useful for both coordinated restore at checkpoint and CDS training runs. Please comment here with a link to that issue so that we can follow along. Should something be added to Cassandra, a Spring Boot issue or pull request to make use of the new capabilities would be welcome.

@wilkinsona wilkinsona closed this Mar 6, 2025
@wilkinsona wilkinsona added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged status: waiting-for-internal-feedback An issue that needs input from a member or another Spring Team labels Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants