Repository navigation
Description
Summary
When reconciliation succeeds but persisting the resulting Task status fails, the worker still acknowledges the triggering event and proceeds to its next queue read.
This can leave the persisted Task status stale relative to the successfully reconciled runtime state until another reconciliation is triggered.
Current behavior
Verified against upstream base c5c1ac5:
The current sequence is:
TaskReconciler.Reconcile succeeds
→ processEvent calls UpdateTaskStatus
→ status persistence returns an error
→ processEvent returns that error
→ Worker.Run logs the processing error
→ Worker.Run still calls Ack for the same event
→ worker proceeds to the next queue read
If the status write did not commit, the reconciliation result is therefore not reflected in the persisted Task.
Characterization test
I added a test-only characterization in commit:
Branch:
The branch is exactly one commit ahead of the upstream base, and only internal/controller/worker_test.go changes. Production code is unchanged.
TestWorkerAcknowledgesEventWhenStatusPersistenceFails uses the real Worker and TaskReconciler, mock Substrate, MemoryStore, and test-only Store/Subscription decorators.
It deterministically verifies that:
- reconciliation succeeds and computes Suspended
- exactly one UpdateTaskStatus attempt is made
- the injected failure occurs before touching the backing store
- the same delivered event is still ACKed successfully
- the persisted Task status remains Pending
- the worker enters its next queue read without retrying reconciliation or status persistence
Channel barriers establish ordering; sleeps are not used as evidence. The focused test also passes under -race.
Redis-backed verification
I separately reproduced the same boundary with Docker Redis 7.4.11 using the real Redis Store and real XACK, while injecting only the status-persistence failure before delegation.
For the delivered event:
- before ACK, XPENDING contained the exact event ID
- XACK returned 1
- afterward, the exact event ID was no longer present in the PEL
- the persisted Task status remained Pending
- no additional reconcile event was added to the stream
- the worker proceeded to wait for another event
No automatic reconciliation occurred during the observation window. This does not imply that a later external Task event could not trigger another reconciliation.
The temporary Redis integration test was removed and is not part of the characterization commit.
Why this is distinct from related issues
- Redis consumer does not recover unacknowledged events after worker failure #351 covers delivered but unacknowledged events that remain pending and are not reclaimed. Here, ACK succeeds and the event leaves the PEL.
- Redis status update can overwrite a concurrently committed task spec edit #352 covers UpdateTaskStatus overwriting a concurrent spec update. Here, the characterized status write does not commit.
- First controller subscription skips task events published before startup #354 covers events published before initial consumer-group creation being skipped. Here, the event is delivered and processed.
- Task is marked Failed permanently when Substrate returns ResourceExhausted (no free workers) instead of staying Pending and retrying #367 covers a transient Reconcile failure being persisted as Failed without automatic retry. Here, reconciliation succeeds; persistence of its result fails.
Impact
This can leave the persisted Task status stale relative to the successfully reconciled runtime state until another reconciliation is triggered.
I could not find a periodic reconciliation, startup scan, status repair loop, or other deterministic recovery path for this exact sequence in the current implementation. A later external Task event can cause another reconciliation.
Design question
Worker.Run intentionally acknowledges processing failures so that a bad Task cannot wedge the queue.
Is that policy also intended to cover failure to persist the result of an otherwise successful reconciliation, or should this boundary have a different durability contract?
Activity
adirothbuilds commentedon Sep 26, 2026
I’ve rebased and validated the fix against current main.
The branch is ready here:
https://github.com/adirothbuilds/ax/tree/test/controller-status-persistence-ack
Commit:
adirothbuilds@8619dbb
The change retries only persistence of the already-computed Task status after a successful reconciliation; it does not rerun reconciliation or repeat Substrate side effects. The event is ACKed once status persistence succeeds, and remains unacknowledged if the bounded retries are exhausted or the context is cancelled.
Regression coverage includes transient recovery, final-attempt success, exhaustion, cancellation, and preservation of the existing ACK policy for reconciliation failures.
#351 remains separate: this change preserves an exhausted event as pending but does not add pending-entry recovery.
I’m currently blocked from opening the PR by the repository’s collaborators_only PR creation policy. I’m happy to open it immediately if external PR creation is enabled or access is granted.
rakyll commentedon Nov 25, 2026
Obsolete: the Redis Streams worker was removed.
We are closing this as part of a cleanup after the significant changes in v0.4.0, because it is probably obsolete or out of scope now. If you think this is a mistake, please reopen it (or leave a comment if you can't reopen it).