Skip to main content
The SHOW JOBS statement lists all of the types of long-running tasks your cluster has performed in the last 12 hours, including: Details for enterprise changefeeds, including the sink URI and full table name, are not displayed on running the SHOW JOBS statement. For details about enterprise changefeeds, including the sink URI 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 dropped tables and dropped indexes, and will execute after the GC TTL has elapsed. These jobs cannot be canceled.
  • CockroachDB automatically retries jobs that fail due to retry errors or job coordination failures, with exponential backoff. The jobs.registry.retry.initial_delay cluster setting 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 CONTROLJOB role option.
  • For changefeeds, users with the CHANGEFEED 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 crdb_internal.jobs table. The jobs.retention_time cluster setting defines how long jobs will be retained in the crdb_internal.jobs table. When CockroachDB checks the jobs table, it will garbage collect 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 garbage collection, or potential data accumulation in the case of changefeeds. See Monitoring paused jobs for detail on metrics to track paused jobs and protected timestamps.

Examples

Show jobs

Filter jobs

You can filter jobs by using SHOW JOBS as the data source for a SELECT 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 zone configurations (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 storage layer 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 cluster setting. Both tables contribute to the crdb_internal.statement_statistics and crdb_internal.transaction_statistics tables, respectively.
  • AUTO CREATE STATS: Creates and updates table statistics.

Filter automatic jobs

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

Show changefeed jobs

You can display specific fields relating to changefeed jobs by running SHOW CHANGEFEED JOBS. These fields include:
  • high_water_timestamp: Guarantees all changes before or at this time have been emitted.
  • readable_high_water_timestamptz: The high_water_timestamp value in TIMESTAMPTZ format for readability.
  • sink_uri: The destination URI of the configured sink for a changefeed.
  • full_table_names: The full name resolution 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 Kafka and Google Cloud Pub/Sub changefeed messages will emit. If you start a changefeed with the split_column_families option targeting a table with multiple column families, the SHOW CHANGEFEED JOBS output will show the topic name with a family placeholder. For example, topic.{family}.
  • format: 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 Response section.
To show an individual changefeed:
Changefeed jobs can be paused, resumed, altered, or canceled.

Filter changefeed jobs

You can filter jobs by using SHOW CHANGEFEED JOBS as the data source for a SELECT 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 SELECT statement, and then filtering the job_type value with the WHERE clause:
Scheme change jobs can be paused, resumed, and canceled.

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 backup schedule, use the schedule’s id:
You can also view multiple schedules by nesting a SELECT clause that retrieves id(s) inside the SHOW JOBS statement:

See also