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

Ctrl-C or crashing during build/watch/test can result in unusable cache that will never complete #121

Closed
niloc132 opened this issue Feb 22, 2022 · 0 comments · Fixed by #184
Labels
bug Something isn't working
Milestone

Comments

@niloc132
Copy link
Member

Presently the only way to fix this is to clean the project and build again, but the plugin should detect this case as best it can and start the task over instead of waiting forever for the other process that originally started the work to finish it.

Several degrees of mitigation, with some assumptions:

  • The process that started the work should somehow mark that it is still running, for example by touching the cache entry directory every 1s or so. If another process detects that the directory is stale by some amount (5s, for example?) we could then assume it to have failed, try to delete it, and start again. Failure mode, on windows the other process might merely be stuck (gc, debugger, etc) and have locked some contents and prevent it from being deleted, the deleting process could either assume it is still being built, or just error out. This would need to be implemented as another thread in the scheduler watching one or more tasks as they work, touching the directories periodically.
  • Separately, a shutdown hook should be added as part of the scheduler, so that on shutdowns where work was in progress, that work should be stopped in some way, or have its output deleted to allow a later build to take over for it. This can also fail if that other process is still trying to finish its work, the shutdown hook can warn if delete fails and inform the user they may need to perform a clean.
  • Finally the DiskCache should detect a directory being deleted while running, and use that to signal that this process should attempt to own that task and start it, allowing one process to halt and another to pick up after it. In order to correctly handle the shutdown hook, it should be shut down before the BuildScheduler is stopped, so a process doesn't try to take over during its own shutdown.

Probably replace "shutdown hook" above with Closable.close() so that the services themselves don't watch for shutdown, but maven or whatever else is using the services can shut them down in the appropriate order. This order in turn should be documented.

@niloc132 niloc132 added the bug Something isn't working label Feb 22, 2022
@niloc132 niloc132 added this to the 0.21 milestone Mar 3, 2022
niloc132 added a commit to niloc132/j2clmavenplugin that referenced this issue Jun 30, 2022
niloc132 added a commit that referenced this issue Jul 12, 2022
This pull request applies the three basic suggestions from #121, to
ensure that a stopping process will either clean up after itself, or
that other processes can detect a stale cache and cancel the work,
start over.

This doesn't go so far as to cancel in-progress work, to permit watch
mode to more quickly start a new build, but it should make this
easier to write.

Fixes #121
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant