prefect icon indicating copy to clipboard operation
prefect copied to clipboard

Duplicate Scheduled Flow Runs Triggered in Prefect 2.18

Open Hafeez-Aqfer opened this issue 5 months ago • 10 comments

Bug summary

When a deployment in Prefect 2.18 is configured with a regular schedule (for example, an hourly IntervalSchedule), the scheduler sometimes emits two flow‐run creation events for the same scheduled timestamp. In practice this looks like:

A flow run is created at the exact top of the interval (e.g. scheduled start time 07:00:00 PM).

Within a few seconds—often 10–20 seconds later—a second flow run is created with that same scheduled start time.

Both runs carry the auto-scheduled tag and point to the same deployment.

Each “duplicate” run has essentially the same scheduled start time (06:03 and 07:03) but a different actual submission timestamp (…:00 vs. …:15, and …:59 vs. …:13), which leads to two runs per interval.

This is causing:

  • Wasted resources, since one of the two runs being run for already run task in successful flow.

  • Data skew, because downstream tasks re-process the same data input and causes issue.

  • Confusion in monitoring, since our dashboards assume exactly one run per interval.

This need to be checked and have some fixes / recommendation. I have attached some screenshots for reference.

Note We cannot yet upgrade to Prefect 3 (see our blocker issue: #15751).

Please suggest some actions on why does the duplicate flow_run even gets scheduled.

We have written internal code to handle this , using read_flow_runs to cancel the flow if there any Running flow_runs. Even the solution turns out to be not working were the response is async.

Image Image Image

Version info

Version:             2.18.0
API version:         0.8.4
Python version:      3.12.3
Git commit:          1006d2d8
Built:               Thu, Apr 18, 2024 4:47 PM
OS/Arch:             linux/x86_64
Profile:             default
Server type:         cloud

Additional context

No response

Hafeez-Aqfer avatar Jul 16 '25 16:07 Hafeez-Aqfer

Hey, I would like to work on it. Can i be assigned? :)

nrnavaneet avatar Jul 17 '25 17:07 nrnavaneet

Hello, we're experiencing the same duplication problem with scheduled flows on our Prefect server.

Version info

Version:        3.4.0
API version:    0.8.4

lax-vtl avatar Jul 28 '25 10:07 lax-vtl

Hello, we're experiencing the same duplication problem with scheduled flows on our Prefect server.

Version info

Version:        3.4.0
API version:    0.8.4

I as well encountered the same with v3.4.4

jim-ngoo avatar Aug 12 '25 05:08 jim-ngoo

Image Image

+1 version 3.4.14

Noordle avatar Aug 29 '25 08:08 Noordle

We're experiencing the same issue Prefect v3.4.15

lax-vtl avatar Sep 25 '25 09:09 lax-vtl

We are experiencing this issue on v2.20.19

jeffrose-relay avatar Oct 28 '25 17:10 jeffrose-relay

Any updates on this?

Update:

  • on our side, we have used schedule in prefect.yaml, and often flow-runs where duplicated, like same 10:00 to be executed.
  • I have changed schedule to schedules and added slug, which solved the issue. Now when we do any kind of redeployment, schedules are not duplicated and properly updated.

idestis avatar Nov 13 '25 09:11 idestis

We are seeing this in 3.4.24. We define our deployments in prefect.yaml and some of them run on a schedule. After re-deploying some of the deployments have duplicated upcoming runs. If we manually disable the schedule and re-enable it, this clears the runs.

How has this bug been open this long? An orchestrator that can't reliably schedule jobs seems like a breaking change.

khu-taproot avatar Nov 14 '25 19:11 khu-taproot

How has this bug been open this long? An orchestrator that can't reliably schedule jobs seems like a breaking change.

I completely agree. This is absurd that this bug is just sitting here and prefect is not acknowledging anything.

jeffrose-relay avatar Nov 17 '25 14:11 jeffrose-relay

hi folks, we'll take a look at this issue - sorry for the delay!

I have changed schedule to schedules and added slug, which solved the issue. Now when we do any kind of redeployment, schedules are not duplicated and properly updated.

fwiw my initial reaction here is that this is the root of the issue. if you don't have a slug, the idempotency key can change and you can get duplicates

however, it seems clear that the handling in the case of no slug needs to be clearer / there might be an issue related to multiple scheduler instances (e.g. in Prefect Cloud)

zzstoatzz avatar Nov 25 '25 17:11 zzstoatzz

why close this issue?

Now when we do any kind of redeployment, schedules are not duplicated and properly updated.

is it fixed without explicitly setting slug?

jim-ngoo avatar Dec 15 '25 14:12 jim-ngoo

@jim-ngoo Closing was unintentional, we're testing a fix at the moment, and our issue tracker can be over zealous.

bunchesofdonald avatar Dec 15 '25 14:12 bunchesofdonald

i have the same issue

Image

S1mpleOW avatar Dec 15 '25 15:12 S1mpleOW

A fix for this issue has been deployed to Prefect Cloud and fixes the issue originally seen by @Hafeez-Aqfer.

I'm going to go ahead and close this issue out, but feel free to re-open if you see new duplicate scheduled runs appear. If you do see new duplicates please include the account id, workspace id, and the pair of flow run ids to better help us track down the issue.

bunchesofdonald avatar Dec 17 '25 18:12 bunchesofdonald