You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: HttpSelfRegistration.close() skips deregistration when a heartbeat re-register cycle is in flight (flaky HttpSelfRegistrationTest on CI) #3132
While CI-testing PR #3131 on windows-latest, HttpSelfRegistrationTest. registrationUsesTenantAndDurableIdentityForHeartbeatAndDelete failed
intermittently with the deleted latch timing out at HttpSelfRegistrationTest.java:106:
org.opentest4j.AssertionFailedError: expected: <true> but was: <false>
at io.agentscope.extensions.aistio.transport.HttpSelfRegistrationTest
.registrationUsesTenantAndDurableIdentityForHeartbeatAndDelete(...:106)
The runner stderr showed aistio: registered runtime-instance-key ...twice,
indicating a heartbeat-failure re-register cycle ran concurrently with close().
Root cause
HttpSelfRegistration.close() gates the control-plane DELETE on registered.get():
if (!registered.get()) {
return; // skips the DELETE even if registeredInstanceId is still set
}
heartbeatSafe() clears registeredbefore re-registering after a
heartbeat failure. If close() runs inside that window (likely on loaded
runners where a heartbeat request can fail), the DELETE is silently skipped:
the instance is leaked on the control plane, and the test's deleted latch
times out. Fast local machines rarely hit the window, which is why the test
is green locally and only flakes on CI.
Impact
Real resource leak: an instance that was registered stays registered on the
control plane after close() (ghost instance).
Flaky CI: HttpSelfRegistrationTest fails under load.
Suggested fix
Make close() best-effort unregister whenever an identity exists
(registeredInstanceId != null), keeping never-registered calls as a no-op
and repeat closes idempotent; widen the test latches from 2s to 10s so slow
runners don't turn slow (not stuck) callbacks into failures.
Fix will be attached to PR #3131 (discovered by its CI run).
Root cause:close() decides whether to send the control-plane DELETE by reading registered, but the heartbeat path clears that flag before re-registering.
agentscope-extensions/agentscope-extensions-aistio/src/main/java/io/agentscope/extensions/aistio/transport/HttpSelfRegistration.java:143-145 — if (!registered.get()) { return; } skips the DELETE even while registeredInstanceId still holds a durable instance key.
HttpSelfRegistration.java:180-183 — on 404, registered.set(false) then tryRegister().
HttpSelfRegistration.java:185-191 — on any heartbeat exception, registered.set(false) then tryRegister().
A close() landing inside that window therefore returns early, and the re-registration that follows is never torn down — exactly the race described.
Impact: a registered instance stays registered on the control plane after close() (ghost instance), and HttpSelfRegistrationTest.registrationUsesTenantAndDurableIdentityForHeartbeatAndDelete times out on the deleted latch at HttpSelfRegistrationTest.java:106 under loaded runners. Severity: medium — a real lifecycle leak, but bounded to the aistio self-registration path.
Fix assessment: the suggested approach is correct and minimal — gate close() on registeredInstanceId != null rather than registered.get(), keep never-registered calls a no-op, and clear the identity in finally so repeat closes stay idempotent. Widening the test latches from 2s to 10s is reasonable hardening for slow runners, but it is secondary: it hides the timing symptom without removing the leak.
PR coordination: this issue says the fix will be attached to #3131, and that PR is already cross-referenced here, so we will not open a competing PR. If you would rather have an independent fix PR for this one, reply /approve and we will generate one.
What this means for the offer above:#3131 is the active path for this fix, so opening our own PR here would only duplicate it — we are treating #3131 as the carrier and are not generating a competing PR. The independent-proposal path in the evaluation above is still available: if you would rather see this fixed separately (for example if #3131 stalls, or a maintainer closes it), say so in this thread and we will open one scoped so it cannot collide with the two files above.
No action is needed from anyone. This window closes on its own on 2026-09-16T17:07Z if the thread stays quiet.
Status: 72 h feedback window expired — no automated PR will be generated, this proposal window here is closed
The evaluation above went 72 hours without an /approve, /revise or /reject, so per our workflow the window is closed and no competing PR will be generated. No action is needed from anyone.
The root cause still stands, and it is still not fixed on main: as of this check origin/main @ 6c8ccc5c6 still gates the deregistration on if (!registered.get()) { return; } in HttpSelfRegistration.close() (agentscope-extensions/agentscope-extensions-aistio/src/main/java/io/agentscope/extensions/aistio/transport/HttpSelfRegistration.java), which is exactly the window the report describes.
The fix is already in flight, carried by the PR this issue was announced alongside:
One mechanical caveat, repeated from the note above so nobody is surprised later: #3131 is not keyword-linked to this issue — its closing references resolve to #3102 — so GitHub will not auto-close #3132 when #3131 merges. If #3131 lands, this issue still needs a manual close, or a Fixes #3132 added to that PR.
What this issue needs next is a maintainer review of #3131, not a second implementation. If maintainers would still like an independent proposal here — for example one scoped to HttpSelfRegistration alone so it cannot collide with #3131's two files — reply on this issue and we will open one.
Hit this again today, on 2.0.x: the Windows job of #4450 (108fae28) failed this test at :106 with the signature described here, aistio: registered ... logged twice.
Two things have changed since the report, which is why I'm picking it up here:
agentscope-extensions-aistio no longer exists on main, so feat(agent): support recovery mechanism for streaming tool call errors #3131 cannot deliver this fix there. On 2.0.x the class is as described (close() still returns early on !registered.get()), and every PR against 2.0.x runs this test on Windows.
The leak is wider than a skipped DELETE. I repeated the test's scenario 300 times on unmodified 2.0.x (Linux, the test's 20 ms heartbeat): in 291 runs the heartbeat that close() interrupted registered the instance again — shutdownNow() lands while the request is on the wire, the catch path takes that for a failure and calls tryRegister() — and in 277 of them that registration reached the server after the DELETE, so the instance is registered again after it was deregistered. The skipped DELETE of this issue showed up once in an earlier batch of 300.
I'd like to fix it on 2.0.x, in HttpSelfRegistration and its test only: no registration once close() has started, close() waiting for the interrupted heartbeat before it deregisters, and deregistering by the registered id instead of the registered flag. With a regression that pins the interleaving. It cannot collide with #3131, which targets main. Shout if you would rather handle it differently.
tryRegister() does nothing once close() has started, and close() deregisters by the registered instance id rather than the registered flag. Two regressions pin the interleavings with a local server that holds a response until close() has run; both fail on the previous code, 9 runs out of 9. The scenario repeated 300 times with the change: no second registration and no skipped DELETE, against 291 and 1 on the unmodified code.
Activity
fix(aistio): close() during a re-register cycle no longer skips dereg…
oss-maintainer commentedon Sep 13, 2026
Issue Evaluation
Category:
bug| Status: ConfirmedVerified against
main@39cd304a.Root cause:
close()decides whether to send the control-plane DELETE by readingregistered, but the heartbeat path clears that flag before re-registering.agentscope-extensions/agentscope-extensions-aistio/src/main/java/io/agentscope/extensions/aistio/transport/HttpSelfRegistration.java:143-145—if (!registered.get()) { return; }skips the DELETE even whileregisteredInstanceIdstill holds a durable instance key.HttpSelfRegistration.java:180-183— on404,registered.set(false)thentryRegister().HttpSelfRegistration.java:185-191— on any heartbeat exception,registered.set(false)thentryRegister().A
close()landing inside that window therefore returns early, and the re-registration that follows is never torn down — exactly the race described.Impact: a registered instance stays registered on the control plane after
close()(ghost instance), andHttpSelfRegistrationTest.registrationUsesTenantAndDurableIdentityForHeartbeatAndDeletetimes out on thedeletedlatch atHttpSelfRegistrationTest.java:106under loaded runners. Severity: medium — a real lifecycle leak, but bounded to the aistio self-registration path.Fix assessment: the suggested approach is correct and minimal — gate
close()onregisteredInstanceId != nullrather thanregistered.get(), keep never-registered calls a no-op, and clear the identity infinallyso repeat closes stay idempotent. Widening the test latches from 2s to 10s is reasonable hardening for slow runners, but it is secondary: it hides the timing symptom without removing the leak.PR coordination: this issue says the fix will be attached to #3131, and that PR is already cross-referenced here, so we will not open a competing PR. If you would rather have an independent fix PR for this one, reply
/approveand we will generate one.Automated evaluation by github-manager-bot
fix(aistio): make close() atomic against in-flight re-registrations
fix(aistio): make close() atomic against in-flight re-registrations
oss-maintainer commentedon Sep 14, 2026
Adjacent-PR advisory — no change to the evaluation above (supplementary context; this proposal window stays open and is not being stood down)
While polling this window, one community PR now claims the fix described above:
08c630f24pushed 2026-09-14T09:56:52Z) — feat(agent): support recovery mechanism for streaming tool call errors. Under "Also fixed (unrelated to [Bug]:ReActAgent 调用不存在的工具时直接退出 ReAct 循环,未给模型重试机会 #3102, found by this PR's CI)" its description names [Bug]: HttpSelfRegistration.close() skips deregistration when a heartbeat re-register cycle is in flight (flaky HttpSelfRegistrationTest on CI) #3132: "HttpSelfRegistration.close()could skip the control-plane DELETE when a heartbeat re-register cycle was in flight (flaky test on a loaded Windows runner)". The PR's file list confirms bothagentscope-extensions-aistio/.../transport/HttpSelfRegistration.javaandHttpSelfRegistrationTest.javaare in the diff, which is the sameregistered.get()gate identified above.Two mechanical notes:
Fixes #3132on that PR.MERGEABLE/APPROVEDwith 6/6 checks green.What this means for the offer above: #3131 is the active path for this fix, so opening our own PR here would only duplicate it — we are treating #3131 as the carrier and are not generating a competing PR. The independent-proposal path in the evaluation above is still available: if you would rather see this fixed separately (for example if #3131 stalls, or a maintainer closes it), say so in this thread and we will open one scoped so it cannot collide with the two files above.
No action is needed from anyone. This window closes on its own on 2026-09-16T17:07Z if the thread stays quiet.
Automated by github-manager-bot
oss-maintainer commentedon Sep 16, 2026
Status: 72 h feedback window expired — no automated PR will be generated, this proposal window here is closed
The evaluation above went 72 hours without an
/approve,/reviseor/reject, so per our workflow the window is closed and no competing PR will be generated. No action is needed from anyone.The root cause still stands, and it is still not fixed on
main: as of this checkorigin/main@6c8ccc5c6still gates the deregistration onif (!registered.get()) { return; }inHttpSelfRegistration.close()(agentscope-extensions/agentscope-extensions-aistio/src/main/java/io/agentscope/extensions/aistio/transport/HttpSelfRegistration.java), which is exactly the window the report describes.The fix is already in flight, carried by the PR this issue was announced alongside:
602e74d614, last updated 2026-09-16T03:27Z) — feat(agent): support recovery mechanism for streaming tool call errors. Its body lists [Bug]: HttpSelfRegistration.close() skips deregistration when a heartbeat re-register cycle is in flight (flaky HttpSelfRegistrationTest on CI) #3132 under "Also fixed (unrelated to [Bug]:ReActAgent 调用不存在的工具时直接退出 ReAct 循环,未给模型重试机会 #3102, found by this PR's CI)", andHttpSelfRegistration.javaplusHttpSelfRegistrationTest.javaare both in its file list. The current diff replaces theregistered.get()early-return with an atomic claim ofregisteredInstanceIdunder a lifecycle lock, re-checks a newclosedflag inside thetryRegister()publish path so a registration completing afterclose()deletes itself, and raises the failed-deregistration log fromFINEtoWARNING. That is the same direction the evaluation recommended, and more: it also closes the "resurrect after close" ordering this issue's race can produce. As of this check feat(agent): support recovery mechanism for streaming tool call errors #3131 isMERGEABLE/APPROVEDwith 5/5 checks green at that head.One mechanical caveat, repeated from the note above so nobody is surprised later: #3131 is not keyword-linked to this issue — its closing references resolve to #3102 — so GitHub will not auto-close #3132 when #3131 merges. If #3131 lands, this issue still needs a manual close, or a
Fixes #3132added to that PR.What this issue needs next is a maintainer review of #3131, not a second implementation. If maintainers would still like an independent proposal here — for example one scoped to
HttpSelfRegistrationalone so it cannot collide with #3131's two files — reply on this issue and we will open one.Automated by github-manager-bot
aiyili commentedon Dec 1, 2026
Hit this again today, on
2.0.x: the Windows job of #4450 (108fae28) failed this test at:106with the signature described here,aistio: registered ...logged twice.Two things have changed since the report, which is why I'm picking it up here:
agentscope-extensions-aistiono longer exists onmain, so feat(agent): support recovery mechanism for streaming tool call errors #3131 cannot deliver this fix there. On2.0.xthe class is as described (close()still returns early on!registered.get()), and every PR against2.0.xruns this test on Windows.DELETE. I repeated the test's scenario 300 times on unmodified2.0.x(Linux, the test's 20 ms heartbeat): in 291 runs the heartbeat thatclose()interrupted registered the instance again —shutdownNow()lands while the request is on the wire, the catch path takes that for a failure and callstryRegister()— and in 277 of them that registration reached the server after theDELETE, so the instance is registered again after it was deregistered. The skippedDELETEof this issue showed up once in an earlier batch of 300.I'd like to fix it on
2.0.x, inHttpSelfRegistrationand its test only: no registration onceclose()has started,close()waiting for the interrupted heartbeat before it deregisters, and deregistering by the registered id instead of theregisteredflag. With a regression that pins the interleaving. It cannot collide with #3131, which targetsmain. Shout if you would rather handle it differently.aiyili commentedon Dec 1, 2026
Opened #4542 against
2.0.x, oneb5d08e9.tryRegister()does nothing onceclose()has started, andclose()deregisters by the registered instance id rather than theregisteredflag. Two regressions pin the interleavings with a local server that holds a response untilclose()has run; both fail on the previous code, 9 runs out of 9. The scenario repeated 300 times with the change: no second registration and no skippedDELETE, against 291 and 1 on the unmodified code.fix(harness): key transcript segments on the sessions route on 2.0.x (#…