question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Duplicate runs scheduled

See original GitHub issue

Description

Occasionally a specific flow will get double-scheduled in the latest version of Prefect server (we’ve run into this bug several times on previous versions). I.e. for a single clock we will get two identical runs at the same time (both visible in the UI, then both executing at the same time).

Unfortunately this does not happen on every scheduler cycle or we could troubleshoot more easily.

This may or may not be relevant, but it only happens on the times when the schedule is set to run with specific parameters. Another clock on the same schedule does not have this problem.

We can temporarily fix it by:

  • Toggling the schedule on and off in the UI (only works sometimes).
  • Deleting the postgres data and re-registering the flow

Expected Behavior

Any unique combination of time, flow, and parameters should only get scheduled once by the server.

Reproduction

Unfortunately we can’t always reproduce it, but this problem eventually recurs even when we completely wipe the server setup and redeploy.

The schedule in question is generated as:

# normally imported from a config:
CRON_TIMES_LOADONLY = ["0 6 * * *"] 
CRON_TIMES_FULLRUN = ["0 9 * * *"]

start_date = pendulum.now(tz="America/Chicago")  # pin clock to CDT
clocks_loadonly = [
    clocks.CronClock(s, start_date=start_date) for s in CRON_TIMES_LOADONLY
]
clocks_fullrun = [
    clocks.CronClock(
        s, start_date=start_date, parameter_defaults={"run-dbtbuild": True}
    )
    for s in CRON_TIMES_FULLRUN
]
schedule = Schedule(clocks=clocks_loadonly + clocks_fullrun)

This definition style hasn’t caused us any issues when not used with parameter defaults.

Environment

{ “config_overrides”: { “server”: { “host”: true, “telemetry”: { “enabled”: true }, “ui”: { “apollo_url”: true } } }, “env_vars”: [], “system_information”: { “platform”: “Linux-4.15.0-118-generic-x86_64-with-glibc2.10”, “prefect_backend”: “cloud”, “prefect_version”: “0.13.14”, “python_version”: “3.8.5” } }

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:9
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
sp1thascommented, Nov 9, 2020

Same here. I also use parameter_defaults. Flow re-registration seems to fix this issue temporarily. In my case, the scheduling is de-regulated after one or two days. Really difficult to reproduce it locally 😕

Environment

{
  "config_overrides": {
    "api": {
      "url": true
    },
    "context": {
      "secrets": false
    },
    "server": {
      "database": {
        "host_port": true
      },
      "ui": {
        "graphql_url": true
      }
    }
  },
  "env_vars": [
    "PREFECT__CONTEXT__SECRETS__...",
    "PREFECT__CONTEXT__SECRETS__..."
  ],
  "system_information": {
    "platform": "Linux-4.19.0-10-amd64-x86_64-with-debian-10.6",
    "prefect_backend": "server",
    "prefect_version": "0.13.14",
    "python_version": "3.7.3"
  }
}
2reactions
joshmeekcommented, Nov 13, 2020

Update: the fix for the duplicate scheduled runs has been merged into server and the next core release will use the updated images 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unexpected or Duplicate Scenario Executions when ...
A particular Scenario is scheduled to be executed by an Oracle Data Integrator (ODI) Agent at 08:00 PM. This configuration has been running...
Read more >
Schedule Duplicate Jobs and Notifications - IdeaExchange
When a scheduled Duplicate Job is run, the results, or a link to results, should be emailed to the user who created the...
Read more >
Prevent duplicate cron jobs running - Server Fault
I have created one jar to solve such issue like duplicate crons are running could be java or shell cron. Just pass cron...
Read more >
Duplicate firing of scheduled tasks? - Playfab Community
An hourly Scheduled Task would run every hour. Are you saying that your Scheduled Tasks ran more than once per their scheduled times?...
Read more >
Duplicate scheduled tasks - support - Lucee Dev
I have several scheduled tasks that run regularly, e.g. every minute, but every now and then the server starts running each task twice...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found