Fix duplicate task generation (frontport of #5431)#5459
Merged
Conversation
The task processor can call `process_actions` multiple times while a previous batch's tasks are still in-flight. When there's a backlog (`schedule.start` far in the past), the deadline timer fires immediately because the next event is also in the past. The `last_requested_callbacks` guard passes, and `next_actions` reads stale on-chain state (schedule.start hasn't advanced yet), generating overlapping timestamps. When both batches are eventually submitted as blocks, batch 2's stale timestamps don't match the now-advanced `schedule.start`, causing: ``` contract.rs:115: assert_eq!(timed_data.timestamp, next_timestamp, "unexpected timestamp in posted data") ``` Introduce an `in_flight_apps: BTreeSet<ApplicationId>` guard in the task processor. When a batch of tasks is spawned for an application, the app is marked as in-flight and subsequent `process_actions` calls skip it. A new `TaskMessage` enum replaces the raw `(ApplicationId, TaskOutcome)` channel, adding a `BatchComplete` variant that the spawned task sends after all outcomes. On `BatchComplete`, the guard is cleared and `process_actions` is re-triggered for that app so it reads freshly-updated on-chain state. - CI - I had a stuck worker with a big backlog. After rebuilding pm-app with this fix and restarting the worker with the new package version, I see no more panics, and it seems that the worker is actually making progress through the backlog: 
Contributor
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This was referenced Feb 17, 2026
ma2bd
approved these changes
Feb 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Motivation
Frontport of #5431 from
testnet_conwaytomain.Proposal
Cherry-pick of #5431 with conflict resolution (adapted
cursorsfield name used onmain).Test Plan
CI.