Skip to content

[Bug]: Durable recovery tests fail intermittently on Linux CI and block unrelated PRs #4175

Closed

Description

@ningmao-hlyz

Summary

Three test classes introduced or rewritten by #4154 (a4306d63) fail intermittently on ubuntu-latest. Each one has failed on pull requests that do not touch the module under test, so this reads as baseline instability rather than a regression from any single change. Right now these failures cost every contributor a re-run and hide real regressions behind a familiar-looking red build.

Status: all four are understood, fixed in #4176

Repeating each class on the same hosted runner (a temporary workflow in that branch, not part of the diff) passes 20/20 for A2A, 20/20 for RocketMQ, 10/10 for ProcessRecoveryTest and 10/10 for HttpServerApplicationTest on ubuntu-latest.

  • A2A: the confirmation arrives before .doFinally removes the task from agentCache, so the runner throws synchronously and the executor answers with a plain Message — no terminal event. The task now releases itself through a latch that doFinally and stop open, and a request for the same task waits up to two seconds for it.
  • RocketMQ: hypothesis 1 was right, hypothesis 2 was not. The fake broker re-offered a message 50ms after handing it out without knowing the consumer was still working on it, so one CANCEL produced two acks. The window is now one second and named; no runtime dedup gap was found, so the fix stays in the test harness.
  • ProcessRecovery: not a stall. The runtime interrupts the ticking thread to deliver a wakeup, and the polling Thread.sleep threw. All three sleeps now clear the flag, as the fixture loop in the same file already did.
  • HttpServerApplicationTest: the cached Spring context outlived the static @TempDir; it is now dirtied after the class, so the context closes before the directory is removed.

Observed on unrelated PRs

Test Failed on What the log shows
AgentScopeAgentExecutorInputRequiredTest.streamingConfirmationWithoutStateStoreFails #3287 (job), #4102 (job), #4103 (job) 0.189s / 0.187s — the stream ends without emitting any terminal event
RocketMqExecutionTest.agentScopeResumesThroughSeparateLedgersDespitePublicationAndAckFailures #3960 (job), #4136 (job, job) 14.86s / 14.22s — the 10s wait is exceeded
ProcessRecoveryTest.replacementCollectsOriginalResultWithoutRepeatingEffect[1] #4102 (job), main (job) InterruptedException from Thread.sleep(20)

HttpServerApplicationTest (@TempDir cleanup, Failed to delete temp directory /tmp/junit-...) is probably a fourth instance of the same pattern but is not analysed here.

RocketMQ recovery: first concrete snapshot

The recovery assertion only says Condition did not become true, so none of the three failures above can be told apart from each other or from a slow machine. I added a snapshot to that one assertion locally (test-only, no behaviour change; PR to follow) and reproduced the failure 1 time in 4 local runs.

Failing run:

turn.status=WAITING, starts=1, queries=1, modelCalls=1,
commandAcks=20, eventAcks=30,
queuedCommands=0, queuedControls=0, queuedEvents=5,
onError=[DurableException: Execution publication unconfirmed,
         DurableException: Execution publication unconfirmed,
         IllegalStateException: Consumer ACK lost]

Passing run, same test:

turn.status=SUCCEEDED, starts=1, queries=1, modelCalls=2,
commandAcks=1, eventAcks=5, queuedEvents=0

So in the failing run the command topic is received and acked about 20 times, the event topic about 6 times, five events are still sitting in the queue, and the turn never reaches its second model call. That looks like delivery amplification, not like a single lost message.

Hypotheses (none confirmed)

  1. The in-test broker's redelivery window is too tight. Broker.consumer re-enqueues any received-but-not-yet-acked message after a fixed 50ms without checking whether it is still in flight. If ack() takes longer than 50ms under CI load, one message becomes several, and every extra delivery costs more work, which makes the next ack slower still — a cascade that fits the 20x/6x counts.
  2. No dedup on the consumer side. The extension has no requestId-level dedup, so duplicates are expected to be absorbed by the runtime state machine. If a duplicated command can still move state, duplicates would explain the turn not progressing.
  3. The 10s budget is simply too short. Not excluded, but a run that acked 20 commands in 14.86s looks stalled rather than slow.

What this report does not claim

At the time of this report none of the three had been root-caused, and no test was skipped, disabled, or weakened to make the build green. A2A and ProcessRecoveryTest are separate failures from the RocketMQ one; the status section above records what each turned out to be.

Question

For the RocketMQ case: is a test-side fix acceptable (only re-enqueue when the message is not in flight, or dedupe by requestId in the fake broker), or should duplicate delivery be treated as a runtime dedup gap and fixed in the extension? I would rather align on that than guess, since the two fixes land in different modules.

Answered: test-side — the duplicates came from the harness window, not from the extension, so #4176 raises the window to one second.

Activity

  1. ningmao-hlyz commented on Nov 14, 2026

    @ningmao-hlyz
    ContributorAuthor

    First pass is in #4176 (test-only, no production code):

    • RocketMQ — the recovery assertion now reports turn status, lastFailure, model/ack counters and queue depths instead of Condition did not become true. This is how the WAITING / commandAcks=20 / queuedEvents=5 snapshot above was obtained.
    • ProcessRecovery — fix. The test polls backend.turn(...) while ticking, and the runtime interrupts the ticking thread to deliver a wakeup; the two polling loops in the test body did not clear the flag, so Thread.sleep threw. They now share the pause helper the fixture loop in the same file already used.
    • A2A — diagnostics only. stream() now lists the events that did arrive. I could not reproduce the failure: 30 repetitions, 30 passes on Windows. Since it fails in 0.19s on Linux I suspect a platform-specific ordering rather than load, but I have no evidence, so no production code is touched and this one stays open.

    If the A2A failure recurs on CI, the new message will name the events the stream emitted before ending, which should be enough to tell "no terminal event at all" from "a terminal event the filter missed".

  2. ningmao-hlyz commented on Nov 14, 2026

    @ningmao-hlyz
    ContributorAuthor

    Root cause found for the RocketMQ entry, and it is in the test harness rather than in the runtime.

    Broker.consumer in RocketMqExecutionTest re-offers a message 50ms after handing it out unless it was acked, without knowing whether the consumer is still working on it. When the ack lands later than 50ms the same message is delivered twice. That is the whole failure:

    authorizationPrecedesAdmissionAndCancellationTombstoneSurvivesLateExecute:604
    expected: <1> but was: <2>
    

    one CANCEL, two acks. Narrowing the window to 1ms reproduces it locally and deterministically, together with the recovery stall:

    expected: <1> but was: <2>
    turn.status=WAITING, modelCalls=1, commandAcks=10, eventAcks=17, queuedEvents=2
    

    So the commandAcks=20 in my earlier comment was not a stuck turn waiting for one result; it was the same command being handed out repeatedly while the consumer was still catching up. A real invisible duration is measured in seconds, and these tests only need redelivery inside their 10s waits, so #4176 raises the window to one second and names the constant.

    ProcessRecoveryTest is confirmed as a third instance of the interrupt, always at the same line (run 43592515698):

    java.lang.InterruptedException: sleep interrupted
      at ProcessRecoveryTest.replacementCollectsOriginalResultWithoutRepeatingEffect(ProcessRecoveryTest.java:254)
    

    Also fixed in #4176 — the fixture loop in that file already cleared the interrupt flag for exactly this reason.

    streamingConfirmationWithoutStateStoreFails (A2A) is untouched and still open. It does not reproduce here (30 repetitions pass, and the whole module passes), and the module has no SLF4J provider, so its CI output carries no executor logging to read a cause from. I would rather leave it open than guess.

  3. CryoThrust commented on Nov 17, 2026

    @CryoThrust
    Contributor

    I hit a post-fix RocketMQ timeout on the unchanged base while investigating the separate ProcessRecoveryTest failure in #4214.

    Baseline: 30dc84b59e646f443dcf1870d66b3225e6210582, which already contains #4176 (2c935368a) and the 1,000 ms fake-broker ACK window. The full Linux build uses Ubuntu / Temurin 17 and the upstream PR Maven command. Its only reported test failure is RocketMqExecutionTest.agentScopeResumesThroughSeparateLedgersDespitePublicationAndAckFailures:

    turn.status=WAITING, lastFailure=none, modelCalls=1,
    commandAcks=3, eventAcks=7, queuedEvents=0
    turn reaches SUCCEEDED did not become true within 10s
    

    The full-build reports are in artifact 14302736460, under full/agentscope-extensions/agentscope-extensions-durable-rocketmq/target/surefire-reports. They contain 13,064 reported tests in total, one failure and no errors. The later five focused repetitions in that job target ProcessRecoveryTest, not RocketMQ; they do not establish a successful RocketMQ rerun.

    This snapshot differs from the earlier 20-command-ACK / nonempty-event-queue observation. I have not established whether this is a remaining fixture timing issue or a runtime/transport issue, and I have not changed the ACK window, wait budget or assertions. Would you prefer tracking this post-fix timeout here or in a separate issue? I am not proposing a competing implementation of the already merged fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions