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

NB can't stop processes which are running as children of reused mvnd daemons #7676

Open
mbien opened this issue Aug 16, 2024 · 3 comments
Open
Labels
GraalVM [ci] enable GraalVM tests kind:bug Bug report or fix Maven [ci] enable "build tools" tests

Comments

@mbien
Copy link
Member

mbien commented Aug 16, 2024

Apache NetBeans version

Apache NetBeans 22

What happened

There is some support for mvnd since NB 13 (#3210) and generally works ok for common build tasks.

However, the stop button can cause problems under some circumstances. It terminates the process tree, the JVM may not be in the tree of the mvnd process though (unless it runs for the first time and is not a reused daemon yet). Pressing stop will kill the mvnd process (which is sometimes just the client), but the "build" will continue running in the daemon.

what works:

  • pressing build, run etc and never pressing stop (let everything exit naturally)
  • killing the child JVM via shell will also work since it will cause "regular" shutdown
  • pressing run while having no mvnd daemons active -> stop will work since it kills the whole process tree which still includes the daemon (it seems to detach once idle)

what doesn't work / reproducer:

  1. press build and wait till it finishes (there is now a daemon available)
  2. press run (program runs as child of the daemon, the mvnd client process won't have any children)
  3. press stop (this will kill the mvnd client process only, rest will continue running)

workaround:
run mvnd --stop before starting tasks where you expect to press stop, or clean up the processes periodically

Language / Project Type / NetBeans Component

java maven project

How to reproduce

see above

Did this work correctly in an earlier version?

No / Don't know

Operating System

linux

JDK

22.0.2, Temurin

Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

No response

Are you willing to submit a pull request?

Yes (likely upstream)

@mbien mbien added kind:bug Bug report or fix Maven [ci] enable "build tools" tests labels Aug 16, 2024
@mbien
Copy link
Member Author

mbien commented Aug 16, 2024

i will likely open some cleanup PRs first, since I updated a few things while debugging this.

@mbien
Copy link
Member Author

mbien commented Aug 22, 2024

in principle, this could be fixed via a small change within mvnd and would also align with what the client already does on SIGINT (ctrl+c). (it sends a cancel message to the connected daemon which cancels the build and makes itself available again for other tasks)

here is a prototype which:

  • adds a JVM shutdown hook which sends the cancel msg on irregular shutdown (SIGTERM)
  • this requires to build the native image with --install-exit-handlers, since without it, GraalVM would not trigger shutdown hooks on irregular shutdowns

The problem however is that the build is also setting -H:-ParseRuntimeOptions for the purpose of delegating -D params instead of parsing them as args. This seems to mess with the signal chaining and prevents the shutdown hook from running again.

This may or may not be a graalvm bug - needs more investigation

(there are other options how to implement this, e.g the daemon could cancel builds once the client connection is gone - it all depends on the requirements)

@mbien mbien added the GraalVM [ci] enable GraalVM tests label Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GraalVM [ci] enable GraalVM tests kind:bug Bug report or fix Maven [ci] enable "build tools" tests
Projects
None yet
Development

No branches or pull requests

1 participant