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

Crac Support - Lifecycle Implementation #1486

Closed
michaelmcfadyensky opened this issue Mar 22, 2024 · 2 comments
Closed

Crac Support - Lifecycle Implementation #1486

michaelmcfadyensky opened this issue Mar 22, 2024 · 2 comments
Labels
status: declined A suggestion or change that we don't feel we should currently apply

Comments

@michaelmcfadyensky
Copy link

To be able to use Crac with spring boot applications, all open connections need to be closed before a checkpoint is taken and then they need to be re-established after a checkpoint is restored.

Spring framework has added in support for automatically stopping any implementations of Lifecycle before the checkpoint and starting them after the checkpoint restore. (spring-projects/spring-framework#29921)

There has been several issues/PRs raised to provide support for this for kafka, web servers, redis, jdbc etc (spring-projects/spring-kafka#2760) however there is currently no support for cassandra.

Currently, if you attempt to take a checkpoint of a spring cassandra app, it will result in the following error.

jdk.internal.crac.CheckpointException
        at java.base/jdk.internal.crac.Core.checkpointRestore1(Core.java:122)
        at java.base/jdk.internal.crac.Core.checkpointRestore(Core.java:246)
        at java.base/jdk.internal.crac.Core.checkpointRestoreInternal(Core.java:262)
        Suppressed: jdk.internal.crac.impl.CheckpointOpenSocketException: tcp localAddr 172.17.0.3 localPort 52866 remoteAddr 172.17.0.5 remotePort 9042
                at java.base/jdk.internal.crac.Core.translateJVMExceptions(Core.java:91)
                at java.base/jdk.internal.crac.Core.checkpointRestore1(Core.java:145)
                ... 2 more

(i've condensed the full error log as its very long)

Requirements

  • To be able to use Crac in a spring boot app with the spring data cassandra starter
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 22, 2024
@christophstrobl
Copy link
Member

Thank you for reaching out. The cassandra driver tries to connect to the db early which opens the socket. Changes contained in #1485 and proposed via spring-projects/spring-boot#39948 allow to defer the actual connect, which in turn may allow to create a checkpoint as long as no interaction with the database happens.
At the moment there's no out of the box solution that allows to capture an in flight snapshot with the CqlSession being initialized. You may want to give the spring-cloud @RefreshScope a try.

@christophstrobl christophstrobl added status: on-hold We cannot start working on this issue yet type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 26, 2024
@mp911de
Copy link
Member

mp911de commented Sep 9, 2024

Spring Data Cassandra's infrastructure support is comprised of FactoryBeans that expect eager initialization as lifecycle processing happens after the factory is expected to return its bean object. The other aspect is that CqlSession is an object that is created and destroyed after usage. CqlSession doesn't expose any lifecycle methods. After destroying the object, it is no longer functional and references to this object need to be discarded in order to obtain a new, connected instance.

We do not plan on adding further utilities in Spring Data Cassandra to widen Checkpoint-Restore arrangements. Any kind of support would have to reside in Spring Boot as Boot's Cassandra support doesn't require Spring Data.

@mp911de mp911de closed this as not planned Won't fix, can't repro, duplicate, stale Sep 9, 2024
@mp911de mp911de added status: declined A suggestion or change that we don't feel we should currently apply and removed status: on-hold We cannot start working on this issue yet type: enhancement A general enhancement labels Sep 9, 2024
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

No branches or pull requests

4 participants