Repository navigation
Conversation
|
u010143241 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
Adds deterministic FIFO barrier (awaitPendingMirrors) to SessionTree for draining pending async mirror operations before HarnessAgent.close(). Correct shutdown ordering, proper interrupt handling, good test coverage replacing unreliable Thread.sleep waits. No issues found.
This comment was marked as abuse.
This comment was marked as abuse.
|
This PR currently conflicts with git fetch origin
git rebase origin/main
# resolve conflicts, then:
git push --force-with-leaseThis is a one-time reminder. Feel free to @mention me for a re-review after conflicts are resolved. Automated notification by github-manager-bot |
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Closing the race between fire-and-forget mirror writes and resource teardown in HarnessAgent.close() is the right goal, and the mockito-based tests that block the mirror executor and assert the drain really waits are a nice touch.
However this work has largely landed on main already, in a bounded form: SessionTree.awaitMirrorQuiescence(long, TimeUnit) is called from HarnessAgent.close() with a 5s timeout (alongside MemoryBackgroundTasks.awaitQuiescence). The PR is also CONFLICTING against main, so a rebase is required either way. Please rebase and reconcile with the existing helper rather than introducing a second, unbounded drain API.
Findings
- [Warning] SessionTree.java:99 — duplicates
awaitMirrorQuiescence(...)already wired intoclose()onmain. - [Warning] SessionTree.java:106 — unbounded
barrier.await()on the static shared executor can wedge every agent'sclose()behind one stuck remote write. - [Info] HarnessAgent.java:382 — unguarded call lets
RejectedExecutionExceptionescapeclose().
Suggestions
// instead of a second API:
if (!SessionTree.awaitMirrorQuiescence(mirrorDrainTimeout, MIRROR_DRAIN_UNIT)) {
log.warn("Session mirror drain did not complete before close(); continuing shutdown");
}Notes
CLA status for the current head: pending. First contribution — thanks for the care in the tests. Please rebase onto main (conflict reminder was already posted) and re-request review.
Automated review by @BOT_SIG@
| * The wait is deliberately uninterruptible so that resource shutdown cannot race an in-flight | ||
| * upload; the interrupted status is restored before returning. | ||
| */ | ||
| public static void awaitPendingMirrors() { |
There was a problem hiding this comment.
[Warning] main already has this exact drain: SessionTree.awaitMirrorQuiescence(long, TimeUnit) (same single-thread executor, submit-and-wait), and HarnessAgent.close() already calls it with a 5s bound plus MemoryBackgroundTasks.awaitQuiescence(5s). Adding a second, unbounded public variant means two overlapping shutdown APIs that will drift. Could you rebase and either drop awaitPendingMirrors() in favour of the existing bounded helper, or state what the unbounded wait buys that the timeout does not (the close()-vs-tempdir race the existing helper documents looks like the same one this PR targets)?
| try { | ||
| CountDownLatch barrier = new CountDownLatch(1); | ||
| MIRROR_EXECUTOR.execute(barrier::countDown); | ||
| barrier.await(); |
There was a problem hiding this comment.
[Warning] No bound on barrier.await(). MIRROR_EXECUTOR is static, shared by every SessionTree in the JVM, and each queued task performs remote I/O (store.appendSegment(...), mirrorToFilesystem(...)). A single hung upload therefore blocks close() of every agent — including sessions that have nothing pending — with no way out except a JVM kill. The bounded form used on main (submit(() -> {}).get(timeout, unit)) keeps shutdown latency finite and logs when it is not met. If an unbounded wait is intentional here, please make the timeout configurable and log a warning when the drain exceeds it.
| if (ownedWorkspaceIndex != null) { | ||
| ownedWorkspaceIndex.close(); | ||
| } | ||
| SessionTree.awaitPendingMirrors(); |
There was a problem hiding this comment.
[Info] The new call sits outside any try/catch, so a RejectedExecutionException from the executor (already shut down during JVM/teardown ordering) now escapes close(). The finally nesting does still close ownedWorkspaceIndex and delegate, but callers that treated close() as non-throwing (e.g. try-with-resources in tests) will start seeing exceptions on shutdown. awaitMirrorQuiescence swallows and logs, which keeps close() total — worth matching.
Summary:
Fixes #2147
Verification: 41 focused Harness/session/memory tests passed; Spotless and git diff check passed.