DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk5 min

Trace pg_cron Failures by Run, Retry, and Cohort

Separate pg_cron jobs, individual runs, and PostgreSQL workers to trace failures accurately. Capture scheduler run IDs alongside application cohort and retry identifiers.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To trace a pg_cron failure across retries and cohorts, capture each scheduled execution separately and add your application’s cohort key and attempt identifier to a durable record or log. A pg_cron job is the schedule definition; a run is one execution; a PostgreSQL background worker is a process that may schedule or execute work. Those are different things, and a worker restart or a later scheduled firing does not prove that a failed SQL command was retried.

What exactly failed: the job, a run, or a worker?

Use the right identity before building a failure timeline. pg_cron stores scheduled job definitions in cron.job. Each time a scheduled command executes, that is a run. Separately, PostgreSQL may use a background worker to track scheduled jobs or execute them, depending on pg_cron’s configuration.

As an Amazon Associate I earn from qualifying purchases.

  • Job: the recurring schedule and command definition.
  • Run: one execution of that command, with its own timing and outcome.
  • Worker: a PostgreSQL process involved in scheduling or executing work. A worker’s lifecycle is not the same as the SQL command’s outcome.

This distinction matters when interpreting logs: a worker crash can disrupt scheduling or execution, while a run record can show a command failure. A later run may simply be the next scheduled firing rather than a retry of the earlier run.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Does pg_cron automatically retry a failed command?

The documented concurrency behavior is not an automatic retry policy. pg_cron can run different jobs in parallel, but only one instance of a particular job runs at a time. If another firing arrives while that job is active, it is queued until the active run finishes. That queueing rule addresses overlap; it does not establish that a failed command will be re-executed.

To establish whether your application retries a failed run, inspect the retry wrapper or orchestration code and its durable attempt records. Do not infer a retry from a subsequent run with the same job ID or from a restarted worker.

Where are pg_cron run errors recorded?

The pg_cron project documents cron.job_run_details for run history and the cron.log_run setting for enabling run-detail logging. The documented default for cron.log_run is on, but deployments can change configuration. The project also documents cron.max_running_jobs with a default of 32; that is a configurable default, not a guarantee about a specific server’s capacity.

Start by checking the installed extension version, the setting, and the actual table definition. Available columns and error details depend on the installed version and deployment, so verify them before using a query copied from elsewhere.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For each execution, preserve whatever your installation exposes for:

  • the scheduler job identifier and run identifier;
  • start and end timestamps;
  • the run status and returned error information;
  • the application cohort key and retry or attempt identifier.

The scheduler’s run history can help identify the job and execution timing, but the reviewed pg_cron documentation does not describe a built-in cohort field. Add cohort and attempt context in application-level logging or a durable application-owned run table, then correlate it with scheduler records.

How do I find why a pg_cron job failed?

  1. Check the job definition. Inspect cron.job to confirm which command and schedule correspond to the affected job.
  2. Find the individual execution. Review cron.job_run_details for the relevant job and time window. Use the installed schema’s actual column names and status values, and retain the run ID and timestamps.
  3. Check scheduler activity. On Supabase, its troubleshooting guide recommends checking pg_stat_activity for the pg_cron scheduler. This is provider-specific guidance, not a universal PostgreSQL recovery procedure.
  4. Inspect PostgreSQL server logs. If the run record does not explain the failure, look for related ERROR, FATAL, or PANIC messages around the run’s timestamps. The run table may not contain enough information to diagnose connection, startup, or broader server problems.
  5. Consider contention and load. Check whether other jobs or database strain could have delayed or prevented execution. Supabase’s guide includes concurrent job load among its troubleshooting checks.
  6. Add application context where needed. If the scheduler record cannot identify which cohort member or retry attempt was involved, log a stable cohort key and attempt ID inside the function or in a durable application-owned record.

Supabase’s advice applies to its managed service context; its extension-version statements and recovery steps should not be generalized to every PostgreSQL installation. For any deployment, correlate run records with the server logs available to that operator.

How can I distinguish a retry from a new scheduled run?

Record both scheduler identity and application identity. The scheduler job and run IDs locate a definition and execution; your application’s cohort key and attempt ID identify the logical work item and the attempt made on its behalf. Together, they let you distinguish cases that otherwise look alike:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Same work item, another attempt: the cohort key stays stable while the application attempt identifier changes.
  • Different cohort members: each work item has its own cohort key, even when both fail under the same scheduled job.
  • Ordinary later firing: a new scheduler run occurs, but there is no evidence it represents another attempt at the earlier logical work item unless the application records that relationship.
  • Scheduler or worker disruption: process or server logs show a lifecycle or availability issue; that alone does not establish that a SQL transaction was retried.

This scheme is an implementation recommendation, not a native pg_cron cohort feature. Make identifiers stable across retries and retain timestamps so records can be correlated even when the scheduler and application logs are stored separately.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What does a background-worker restart tell you?

PostgreSQL’s background-worker registration includes bgw_restart_time, which controls the interval before a crashed registered worker is restarted, or can be set to BGW_NEVER_RESTART. This setting concerns the process lifecycle. It does not specify whether a scheduled SQL command is retried, whether a transaction committed, or whether repeating its side effects is safe.

For retry behavior, inspect the application’s retry mechanism and the command’s transaction and side-effect handling. Treat worker restart evidence and execution outcome evidence as separate parts of the timeline.

Which evidence source should you use?

Evidence source What it identifies What it can help reveal Context and limits
cron.job Job definition Which scheduled command and schedule are involved Does not by itself identify an individual run’s outcome
cron.job_run_details and cron.log_run Individual execution Run timing, status, and error information available in the installed deployment Check installed version, configuration, and actual columns; does not inherently provide application cohort context
PostgreSQL server logs Server and process events around execution Errors or failures not explained by run records, including connection or broader server issues Available detail depends on deployment logging and access
Application-owned run records or logs Logical work item and attempt Which cohort member and retry attempt produced an error Requires the application to record stable identifiers and correlate them with scheduler runs
Worker registration and lifecycle evidence Background-worker process Whether PostgreSQL is configured to restart a crashed registered worker Does not establish SQL retry behavior or successful replay

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.