Skip to main content
The SHOW JOBS lists all of the types of long-running tasks your cluster has performed in the last 12 hours, including:
  • Schema changes through , , , and
  • .
  • Enterprise and .
  • .
  • created for use by the . To view , use SHOW AUTOMATIC JOBS.
Details for , including the and full table name, are not displayed on running the SHOW JOBS statement. For details about , including the and the full table name, use SHOW CHANGEFEED JOBS. To block a call to SHOW JOBS that returns after all specified job ID(s) have a terminal state, use SHOW JOBS WHEN COMPLETE. The statement will return a row per job ID, which provides details of the job execution. Note that while this statement is blocking, it will time out after 24 hours.

Considerations

  • The SHOW JOBS statement shows only long-running tasks.
  • While the SHOW JOBS WHEN COMPLETE statement is blocking, it will time out after 24 hours.
  • Garbage collection jobs are created for and , and will execute after the has elapsed. These jobs cannot be canceled.
  • CockroachDB automatically retries jobs that fail due to or job coordination failures, with exponential backoff. The jobs.registry.retry.initial_delay sets the initial delay between retries and jobs.registry.retry.max_delay sets the maximum delay.

Required privileges

You must have at least one of the following to run SHOW JOBS:
  • The VIEWJOB privilege, which can view all jobs (including admin-owned jobs).
  • Be a member of the admin role.
  • The .
  • For changefeeds, users with the privilege on a set of tables can view changefeed jobs running on those tables.

Synopsis

show_jobs syntax diagram

Parameters

Response

The output of SHOW JOBS lists ongoing jobs first, then completed jobs within the last 12 hours. The list of ongoing jobs is sorted by starting time, whereas the list of completed jobs is sorted by finished time. To view details for jobs older than 12 hours, you can query the table. The jobs.retention_time defines how long jobs will be retained in the crdb_internal.jobs table. When CockroachDB checks the jobs table, it will jobs details for any completed job that has reached the configured retention time. The default value of jobs.retention_time is 14 days. The following fields are returned for each job: For details of changefeed-specific responses, see SHOW CHANGEFEED JOBS.

Job status

We recommend monitoring paused jobs to protect historical data from , or potential data accumulation in the case of . See for detail on metrics to track paused jobs and .

Examples

Show jobs

Filter jobs

You can filter jobs by using SHOW JOBS as the data source for a statement, and then filtering the values with the WHERE clause.

Show automatic jobs

The job types of automatic jobs are:
  • AUTO SPAN CONFIG RECONCILIATION: A continuously running job that ensures that all declared (ALTER … CONFIGURE ZONE …) are applied. For example, when num_replicas = 7 is set on a table, the reconciliation job listens in on those changes and then informs the underlying to maintain 7 replicas for the table.
  • AUTO SQL STATS COMPACTION: An hourly job that truncates the internal system.statement_statistics and system.transaction_statistics table row counts to the value of the sql.stats.persisted_rows.max . Both tables contribute to the and tables, respectively.
  • AUTO CREATE STATS: Creates and updates .

Filter automatic jobs

You can filter jobs by using SHOW AUTOMATIC JOBS as the data source for a statement, and then filtering the values with the WHERE clause.

Show changefeed jobs

You can display specific fields relating to jobs by running SHOW CHANGEFEED JOBS. These fields include:
  • : Guarantees all changes before or at this time have been emitted.
  • readable_high_water_timestamptz: The high_water_timestamp value in format for readability.
  • : The destination URI of the configured sink for a changefeed.
  • full_table_names: The full for a table. For example, defaultdb.public.mytable refers to the defaultdb database, the public schema, and the table mytable.
  • topics: The topic name to which and changefeed messages will emit. If you start a changefeed with the option targeting a table with , the SHOW CHANGEFEED JOBS output will show the topic name with a family placeholder. For example, topic.{family}.
  • : The format of the changefeed messages, e.g., json, avro.
SHOW CHANGEFEED JOBS will return all changefeed jobs from the last 12 hours. For more information on the retention of job details, refer to the Response section.
To show an individual changefeed:
Changefeed jobs can be , , , or .

Filter changefeed jobs

You can filter jobs by using SHOW CHANGEFEED JOBS as the data source for a statement, and then filtering the values with a WHERE clause. For example, you can filter by the status of changefeed jobs:
You can filter the columns that SHOW CHANGEFEED JOBS displays using a SELECT statement:

Show schema changes

You can show just schema change jobs by using SHOW JOBS as the data source for a statement, and then filtering the job_type value with the WHERE clause:
jobs can be , , and .

Show job when complete

To block SHOW JOB until the provided job ID reaches a terminal state, use SHOW JOB WHEN COMPLETE:

Show jobs for a schedule

To view jobs for a specific , use the schedule’s id:
You can also view multiple schedules by nesting a that retrieves id(s) inside the SHOW JOBS statement:

See also