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

Allow inspectionTick cancelling in overridden postStop method for NonBlockingProcess sub-classes #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Allow inspectionTick cancelling in overridden postStop method for NonBlockingProcess sub-classes #78

wants to merge 1 commit into from

Conversation

timaliberdov
Copy link

I'd like to be able to override the postStop method of NonBlockingProcess actor (in particular, to change the method of the process destruction or something like that, so I don't want to call the super.postStop in my new sub-class) and have the ability to cancel the inspectionTick Cancellable (since it's private for now). Therefore, I propose to make this val protected.

@huntc
Copy link
Contributor

huntc commented Aug 7, 2018

Thanks for this. Can you please expand on what your use case is?

@timaliberdov
Copy link
Author

Yeah, sure. I need to stop process gracefully, and postStop uses process.destroy() with force=true. Unfortunately, this boolean parameter is not the only problem for me: NuProcess for Windows in destroy method calls native win32 function TerminateProcess regardless of the force argument value, so I want to achieve a different behavior by overriding postStop method.

@huntc
Copy link
Contributor

huntc commented Aug 7, 2018

You should be able to send a Destroy message to the actor, which should then send SIGTERM. PostStop should only occur after a period of time if SIGTERM failed. I’m unsure then why you need to override anything.

@timaliberdov
Copy link
Author

As I said earlier, on Windows, the kernel32.dll function TerminateProcess is called in process.destroy() method, even if the force argument is false. And this function just terminates process forcibly, as if SIGKILL was sent. After such abnormal termination some of the processes (in my case this is InnoDB) can't recover properly on next startup. It would be nice if I could avoid calling the process.destroy() (and define something by myself to do graceful stop), at least for Windows users. I understand, that I can override the receive function for some messages and use default version for remaining types of messages. And it is OK, but if actor for some reason stops and postStop is called, I'd like to be able to use soft termination. The only thing that is bothering me is that I can't cancel the inspectionTick without using existing postStop and process.destroy(true) in it. Maybe we could make a new protected method that just cancels it instead of making the val protected. What do you think?

@huntc
Copy link
Contributor

huntc commented Aug 8, 2018

What could we do here:

https://github.com/typesafehub/akka-contrib-extra/blob/master/src/main/scala/akka/contrib/process/NonBlockingProcess.scala#L238

... to work-around the Windows behavior that you cite?

@timaliberdov
Copy link
Author

I'm not 100% sure, but it seems like executing taskkill with /pid key and without /f helped. I don't think that it is a good idea to use this in a library code.

Also I found out that when, for example, we install our desktop version of an application on top of the running instance, windows service is being forcibly stopped => all actors are stopped too and we get force destroy in postStop. Is it possible to allow redefining the postStop with ability to cancel the inspectionTick (for example, when actor was stopped but application is still running, so that scheduled runnable won't be spamming Inspect messages to the stopped actor)?

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

Successfully merging this pull request may close these issues.

2 participants