You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@grails.apache.org by "borinquenkid (via GitHub)" <gi...@apache.org> on 2026/07/21 21:57:11 UTC
[PR] Fix flaky RunningApplicationProcessSpec by widening the stop() timeout budget [grails-core]
borinquenkid opened a new pull request, #16032:
URL: https://github.com/apache/grails-core/pull/16032
## Summary
`RunningApplicationProcessSpec > stop terminates a running process and removes the PID
file` is flaky (~2% of runs per apache/grails-core#16030), 0 hard failures — same
commit, different outcome on rerun.
## Root cause
`RunningApplicationProcess.stop()` already behaves correctly: it calls
`process.destroy()`, blocks on `ProcessHandle.onExit()`, falls back to
`destroyForcibly()`, and its final check queries the OS process table directly
(`!process.isAlive()`) — accurate regardless of reaper-thread scheduling. The bug is
purely a timing budget: the test's 15s total wasn't enough headroom for the JVM's
process-reaper notification under CI contention (many parallel Gradle forks each
spawning child processes), occasionally causing `stop()` to report `STILL_RUNNING`
instead of `STOPPED`.
This file was already patched twice before for a related Windows race
(6c76333ea9/a13c38c3fd) — those touched the test's tail assertion but never this
timeout budget.
## Fix
No production code changed — `awaitExit()`'s fallback is already correct, so hardening
it further would add complexity without addressing the actual bottleneck. Bumped the
test's `stop(pidFile, 15000)` call to `30000`ms, giving realistic headroom on a
contended runner. Smallest reviewable diff.
## Testing
- `:grails-shell-cli:test` (full module): 3 separate runs (forced-fresh,
isolated-fresh-JVM `--rerun-tasks --no-daemon`, and cached) all BUILD SUCCESSFUL,
target spec passing in each.
- No new test coverage required (no production change); reviewed that the existing
test still fully exercises real stop-terminates-process behavior.
- CodeNarc/Checkstyle: clean, including a full repo-wide `aggregateStyleViolations`
run (740 tasks).
Related: apache/grails-core#16030
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix flaky RunningApplicationProcessSpec by widening the stop() timeout budget [grails-core]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #16032:
URL: https://github.com/apache/grails-core/pull/16032#issuecomment-5039645806
## [Codecov](https://app.codecov.io/gh/apache/grails-core/pull/16032?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 51.4753%. Comparing base ([`6d1acad`](https://app.codecov.io/gh/apache/grails-core/commit/6d1acaddb6bf52db63370ade4e4ee8ec89d54bd3?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`e71d9fa`](https://app.codecov.io/gh/apache/grails-core/commit/e71d9fad23c791c88adbe9b967fd9c3cc66a3eba?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 17 commits behind head on 8.0.x.
<details><summary>Additional details and impacted files</summary>
[](https://app.codecov.io/gh/apache/grails-core/pull/16032?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## 8.0.x #16032 +/- ##
================================================
+ Coverage 0 51.4753% +51.4753%
- Complexity 0 17754 +17754
================================================
Files 0 2039 +2039
Lines 0 95537 +95537
Branches 0 16571 +16571
================================================
+ Hits 0 49178 +49178
- Misses 0 39056 +39056
- Partials 0 7303 +7303
```
[see 2039 files with indirect coverage changes](https://app.codecov.io/gh/apache/grails-core/pull/16032/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
</details>
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix flaky RunningApplicationProcessSpec by widening the stop() timeout budget [grails-core]
Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on code in PR #16032:
URL: https://github.com/apache/grails-core/pull/16032#discussion_r3652270114
##########
grails-shell-cli/src/test/groovy/org/grails/cli/gradle/RunningApplicationProcessSpec.groovy:
##########
@@ -208,8 +208,8 @@ class RunningApplicationProcessSpec extends Specification {
expect:
RunningApplicationProcess.isRunning(pidFile)
- when:
- def result = RunningApplicationProcess.stop(pidFile, 15000)
+ when: "a generous timeout budget gives headroom for reaper-notification lag on a contended CI runner"
Review Comment:
The block description explains why the number is large rather than what the stimulus is, so the Spock report ends up reading `when: a generous timeout budget gives headroom for reaper-notification lag on a contended CI runner` for a step whose stimulus is simply "the application is stopped". It also undersells the change: `30000` is not an arbitrary generous value, it is exactly what the shipped `stop-app` passes (`grails-profiles/base/commands/stop-app.groovy:31`). Saying that makes this an alignment with production instead of a number we grew until the test stopped failing.
```groovy
when: "the application is stopped"
// Same budget the shipped stop-app command passes (grails-profiles/base/commands/stop-app.groovy)
def result = RunningApplicationProcess.stop(pidFile, 30_000)
```
Also `30_000` for consistency with the `3_600_000L` literals already in this file. If you want to go further, hoisting the value onto `RunningApplicationProcess` (`static final long DEFAULT_STOP_TIMEOUT_MILLIS = 30_000L`) and using it from both `stop-app.groovy` and here would leave one source of truth instead of two copies of the same magic number - fine to skip if you would rather keep the diff minimal.
##########
grails-shell-cli/src/test/groovy/org/grails/cli/gradle/RunningApplicationProcessSpec.groovy:
##########
@@ -208,8 +208,8 @@ class RunningApplicationProcessSpec extends Specification {
expect:
RunningApplicationProcess.isRunning(pidFile)
- when:
- def result = RunningApplicationProcess.stop(pidFile, 15000)
+ when: "a generous timeout budget gives headroom for reaper-notification lag on a contended CI runner"
+ def result = RunningApplicationProcess.stop(pidFile, 30000)
Review Comment:
This is the part I would like confirmed before merge.
`stop()` can only return `STILL_RUNNING` if `awaitExit()` returns false twice: once after the `timeoutMillis` wait on `onExit()`, and again 5s after `destroyForcibly()` (note `Math.min(timeoutMillis, 5000L)` - the second budget does not move with this change, so the effective total goes 20s -> 35s). Both of those returns fall through to `!process.isAlive()`, a direct OS liveness check. For the target here - `sleep 60` / `ping -n 60 127.0.0.1`, hit with `destroy()` and then `destroyForcibly()` - the OS still reporting it alive ~20s later is hard to credit. `NOT_RUNNING` is ruled out by the `expect: isRunning(pidFile)` immediately above. So I do not think the 15s budget is what produced the failure.
The candidate I would check first is the tail condition seven lines down, `process.waitFor(10, TimeUnit.SECONDS)`. It returns `false` - a failing Spock condition - when the test JVM's own bookkeeping for its child has not caught up within 10s, which is precisely the reaper-notification lag the description blames, and this PR leaves its 10s budget untouched. That tail is also what 6c76333ea9/a13c38c3fd were fixing. If that is the condition failing on CI, this change will not stop the flake and the fix belongs there instead - an unbounded `process.waitFor()`, or a `PollingConditions` wait on `!process.isAlive()`.
Worth ruling out as well: `stop()` discards the boolean returned by `destroy()`/`destroyForcibly()`, so a signal that never landed is indistinguishable from a slow shutdown. Not something to fix in this PR, but it is the other way `STILL_RUNNING` happens without any timeout being too short.
The Spock output from one flaky run settles which of these it is, since it prints the rendered condition and the actual `StopResult`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix flaky RunningApplicationProcessSpec by widening the stop() timeout budget [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #16032:
URL: https://github.com/apache/grails-core/pull/16032#issuecomment-5149313886
## ✅ All tests passed ✅
🏷️ Commit: 3811fcefc763c15993095c39c5b2eae11043bfa7
▶️ Tests: 53154 executed
⚪️ Checks: 60/60 completed
---
_Learn more about TestLens at [testlens.app](https://testlens.app)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix flaky RunningApplicationProcessSpec by widening the stop() timeout budget [grails-core]
Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty merged PR #16032:
URL: https://github.com/apache/grails-core/pull/16032
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix flaky RunningApplicationProcessSpec by widening the stop() timeout budget [grails-core]
Posted by "borinquenkid (via GitHub)" <gi...@apache.org>.
borinquenkid commented on code in PR #16032:
URL: https://github.com/apache/grails-core/pull/16032#discussion_r3694123764
##########
grails-shell-cli/src/test/groovy/org/grails/cli/gradle/RunningApplicationProcessSpec.groovy:
##########
@@ -208,8 +208,8 @@ class RunningApplicationProcessSpec extends Specification {
expect:
RunningApplicationProcess.isRunning(pidFile)
- when:
- def result = RunningApplicationProcess.stop(pidFile, 15000)
+ when: "a generous timeout budget gives headroom for reaper-notification lag on a contended CI runner"
Review Comment:
Done — the `when:` label now reads `"the application is stopped"`, and there's a comment noting `30_000` matches the value `stop-app.groovy:31` passes in production, rather than framing it as an arbitrary generous number. Kept the underscore style consistent with the `3_600_000L` literals already in the file. Left the `DEFAULT_STOP_TIMEOUT_MILLIS` hoist out per your "fine to skip" note, to keep the diff minimal.
##########
grails-shell-cli/src/test/groovy/org/grails/cli/gradle/RunningApplicationProcessSpec.groovy:
##########
@@ -208,8 +208,8 @@ class RunningApplicationProcessSpec extends Specification {
expect:
RunningApplicationProcess.isRunning(pidFile)
- when:
- def result = RunningApplicationProcess.stop(pidFile, 15000)
+ when: "a generous timeout budget gives headroom for reaper-notification lag on a contended CI runner"
+ def result = RunningApplicationProcess.stop(pidFile, 30000)
Review Comment:
You were right — the 15s→30s `stop()` budget wasn't the fix. Replaced the tail `process.waitFor(10, TimeUnit.SECONDS)` with a `PollingConditions` wait on the OS-backed liveness check, same idea as your suggested alternatives.
One more round worth flagging: my first pass at that polled `process.isAlive()` (`java.lang.Process`), reasoning it was OS-backed like `stop()`'s own fallback. Checked the JDK 21 source to confirm and that's wrong — `Process#isAlive()` is `!hasExited`, set only when the same async `ProcessHandleImpl` reaper-thread completion that backs `waitFor()`/`onExit()` resolves. It's not a live query, so polling it would've just re-widened the same budget from 10s to 30s rather than removing the dependency you flagged. Fixed to poll `process.toHandle().isAlive()` instead, which delegates to `ProcessHandleImpl`'s native `isAlive0()` — a genuine per-call OS check, matching what `awaitExit()`'s fallback actually relies on. That version is pushed now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix flaky RunningApplicationProcessSpec by widening the stop() timeout budget [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #16032:
URL: https://github.com/apache/grails-core/pull/16032#issuecomment-5040026654
## ✅ All tests passed ✅
🏷️ Commit: e71d9fad23c791c88adbe9b967fd9c3cc66a3eba
▶️ Tests: 15935 executed
⚪️ Checks: 60/60 completed
---
_Learn more about TestLens at [testlens.app](https://testlens.app)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org