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

Close all resources gracefully on JVM shutdown #98

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

the123saurav
Copy link
Contributor

This change closes all resources(store, aof) on JVM shutdown.
It also introduces a notion of state in server and adds check on API methods to prevent misuse/race conditions.

@the123saurav the123saurav self-assigned this Dec 24, 2021
@the123saurav the123saurav added the enhancement New feature or request label Dec 24, 2021
@tuhuynh27 tuhuynh27 added this to the First Release milestone Dec 24, 2021
public void close() {
lock.lock();
try {
chronicleMap.close();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @the123saurav, please consider this case https://github.com/OpenHFT/Chronicle-Map/blob/ea/docs/CM_Tutorial.adoc#close-chroniclemap

If you call close() too early before you have finished working with the map, this can cause your JVM to crash. Close MUST be the last thing that you do with the map.

So, although it is recommended that you close() when you have finished with the map, it is not something that you must do; it’s just something that we recommend you should do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm good point. But does that stop us from calling this?
It will be called from 2 places:

  • During JVM shutdown: In this case we are guranteed to not get any calls.
  • User initiates shutdown in embedded mode. In this case we can just add to our doc, that this should be the last thing done to KevaServer.

I am also okay to remove this from shutdown procedure.
Kindly let me know.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure @the123saurav, I think we can add that warning to our doc

@tuhuynh27 tuhuynh27 changed the title shutdown all resources on JVM shutdown Close all resources gracefully on JVM shutdown Dec 26, 2021
Copy link
Member

@tuhuynh27 tuhuynh27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tuhuynh27
Copy link
Member

Can this be merged now? @the123saurav

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants