Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Duplicate workflow reminder execution in Scheduler mode #7983

Merged
merged 3 commits into from
Aug 13, 2024

Conversation

JoshVanL
Copy link
Contributor

@JoshVanL JoshVanL commented Aug 12, 2024

Workflow reminders must have a period set of repeating forever. This is what fundamentally ensures the durability of Workflows.

PR updates all workflow reminders to have an infinite period.

Workflow reminders repeat execution every 1 minute. In some cases, such as during extremely high load, a workflow reminder may execute whilst a previous execution is still in progress. This leads to situations such as double activity invocation. This patch adds a duplicate internal reminder detector, which silently returns if a duplicate reminder is detected.

Removes the background contexts to Scheduler APIs. The Scheduler API server must respect inbound client contexts.

Removes unused --placement flag from the Scheduler.

Workflow reminders must have a period set of repeating forever. This is
what fundamentally ensures the durability of Workflows.

PR updates all workflow reminders to have an infinite period.

Workflow reminders repeat execution every 1 minute. In some cases, such
as during extremely high load, a workflow reminder may execute whilst a
previous execution is still in progress. This leads to situations such
as double activity invocation. This patch adds a duplicate internal
reminder detector, which silently returns if a duplicate reminder is
detected.

Removes the background contexts to Scheduler APIs. The Scheduler API
server must respect inbound client contexts.

Removes unused `--placement` flag from the Scheduler.

Signed-off-by: joshvanl <me@joshvanl.dev>
@JoshVanL JoshVanL requested review from a team as code owners August 12, 2024 22:37
@cicoyle
Copy link
Contributor

cicoyle commented Aug 12, 2024

I've confirmed the db is clean after several thousand workflow iterations and the reminders are not triggered indefinitely even while removing the Repeat from 2, should be good with this diff 👍🏻

cicoyle
cicoyle previously approved these changes Aug 12, 2024
pkg/actors/actors.go Show resolved Hide resolved
@mikeee mikeee mentioned this pull request Aug 13, 2024
Signed-off-by: joshvanl <me@joshvanl.dev>
artursouza
artursouza previously approved these changes Aug 13, 2024
@artursouza
Copy link
Member

Approved, pending validation to pass.

@artursouza artursouza added the automerge Allows DaprBot to automerge and update PR if all approvals are in place label Aug 13, 2024
Signed-off-by: joshvanl <me@joshvanl.dev>
@cicoyle
Copy link
Contributor

cicoyle commented Aug 13, 2024

LGTM. Just ran my local test and saw the duplicated triggering since the run activity took longer than a minute and saw the log about ignoring it since one is still active, then deleting it. Post workflow run of 4k workflow iterations my db was clean still 👍🏻

scheduler-0-1      | time="2024-08-13T13:49:41.788503301Z" level=debug msg="Triggering job: actorreminder||default||dapr.internal.default.workflow-a.activity||2953-1::0::1||run-activity" instance=bcbc20ef8d3b scope=dapr.scheduler.server type=log ver=edge
scheduler-0-1      | time="2024-08-13T13:50:41.004162967Z" level=debug msg="Triggering job: actorreminder||default||dapr.internal.default.workflow-a.activity||2953-1::0::1||run-activity" instance=bcbc20ef8d3b scope=dapr.scheduler.server type=log ver=edge

workflow-dapr-a-1  | time="2024-08-13T13:50:51.394679014Z" level=debug msg="Executing reminder for internal actor 'dapr.internal.default.workflow-a.activity||2953-1::0::1||run-activity'" app_id=workflow-a instance=e455363315f3 scope=dapr.runtime.actor type=log ver=edge
workflow-dapr-a-1  | time="2024-08-13T13:50:51.394693722Z" level=debug msg="Duplicate concurrent reminder invocation detected for 'dapr.internal.default.workflow-a.activity||2953-1::0::1||run-activity', likely due to long processing time. Ignoring in favour of the active invocation" app_id=workflow-a instance=e455363315f3 scope=dapr.runtime.actor type=log ver=edge
workflow-dapr-a-1  | time="2024-08-13T13:50:51.394715305Z" level=debug msg="Deleting reminder which was cancelled: dapr.internal.default.workflow-a.activity||2953-1::0::1||run-activity" app_id=workflow-a instance=e455363315f3 scope=dapr.runtime.actor type=log ver=edge

@dapr-bot dapr-bot merged commit af20c14 into dapr:release-1.14 Aug 13, 2024
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Allows DaprBot to automerge and update PR if all approvals are in place
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants