The job queue coordinator process (CJQ0) selects jobs that need to be run from the data dictionary and spawns job queue worker processes (Jnnn) to run the jobs. Oracle Scheduler automatically starts and stops CJQ0 as needed. The JOB_QUEUE_PROCESSES
initialization parameter specifies the maximum number of processes that can be created for running jobs. CJQ0 starts only as many job queue processes as are required by the number of jobs to run and the available resources.
Jnnn processes run jobs that the job coordinator assigns. When workers pick jobs for processing, they do the following:
- Gather all the metadata that is needed to run the job (for example, program arguments and privilege information).
- Start a database session as the owner of the job, start a transaction, and then start running the job.
- Commit and end the transaction after the job is complete.
- Close the session.
When a job is done, the workers do the following:
- Reschedule the job if required.
- Update the state in the job table to reflect whether the job has completed or is scheduled to run again.
- Insert an entry into the job log table.
- Update the run count and, if necessary, the failure and retry counts.
- Clean up.
- Look for new work. (If there is none, they go to sleep.)
Both CJQ0 and Jnnn can run as threads or as operating system processes.