Skip to Main Content
  • Questions
  • DBMS_JOB.SUBMIT doesn't do anything in Oracle 12c (12.2.0.1.0)

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question.

Asked: September 26, 2018 - 2:31 pm UTC

Last updated: May 30, 2020 - 7:43 am UTC

Version: 12.2.0.1.0

Viewed 10K+ times! This question is

You Asked

Hi guys,

I have a problem when I try to start a stored procedure with DBMS_JOB.SUBMIT.

I have the package "dafneMultithread":

CREATE OR REPLACE PACKAGE DAFNE.dafneMultithread AS

    PROCEDURE start_job(p_procedure_name IN VARCHAR2);

END dafneMultithread;
/


and the package body:

CREATE OR REPLACE PACKAGE BODY DAFNE.dafneMultithread AS

    PROCEDURE start_job(p_procedure_name IN VARCHAR2) IS

    v_job NUMBER;        -- ID of the job

    BEGIN
        DBMS_JOB.SUBMIT(v_job, p_procedure_name);

        COMMIT;
    END start_job;

END dafneMultithread;
/


The issue is that when I try to execute the procedure with this script:

DECLARE 
BEGIN
    dafneMultithread.start_job('cmpHpfmsPostAMDService;');
END;
/


works well but the procedure doesn't start (TOAD shows a succesfull message).

However, in a version Oracle 11 works fine (the procedure starts).

So, What is the problem?

The job_queue_processes is greater than 0 and if I check the table user_jobs I see that appears the procedures that I execute with the script:

1 DAFNE DAFNE DAFNE     26/09/2018 12:34:10 12:34:10 0 N null  cmpHpfmsPostAMDAccount; NLS_LANGUAGE='AMERICAN' NLS_TERRITORY='AMERICA' NLS_CURRENCY='$' NLS_ISO_CURRENCY='AMERICA' NLS_NUMERIC_CHARACTERS='.,' NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss' NLS_DATE_LANGUAGE='AMERICAN' NLS_SORT='BINARY' 0102000000000000 0
2 DAFNE DAFNE DAFNE     26/09/2018 12:34:28 12:34:28 0 N null  cmpHpfmsPostAMDContact; NLS_LANGUAGE='AMERICAN' NLS_TERRITORY='AMERICA' NLS_CURRENCY='$' NLS_ISO_CURRENCY='AMERICA' NLS_NUMERIC_CHARACTERS='.,' NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss' NLS_DATE_LANGUAGE='AMERICAN' NLS_SORT='BINARY' 0102000000000000 0


So, it seems that there are a problem with the starting of the jobs, isn't it?

Thanks!
Regards.

and Connor said...

Are you it *never* starts? Or just starts later than expected ?

I'm seeing some latency in my *first* submissions after startup, eg

SQL> create table t
  2   ( submitted timestamp,
  3     started   timestamp );

Table created.

SQL>
SQL> create or replace
  2  procedure prc is
  3  begin
  4    update t set started = systimestamp;
  5    commit;
  6  end;
  7  /

Procedure created.

SQL>
SQL> declare
  2    j int;
  3  begin
  4    dbms_job.submit( j,'prc;');
  5    insert into t(submitted) values (systimestamp);
  6    commit;
  7  end;
  8  /

PL/SQL procedure successfully completed.

SQL>
SQL> select * from t;

SUBMITTED
---------------------------------------------------------------------------
STARTED
---------------------------------------------------------------------------
27-SEP-18 01.01.58.280000 PM


SQL> /

SUBMITTED
---------------------------------------------------------------------------
STARTED
---------------------------------------------------------------------------
27-SEP-18 01.01.58.280000 PM
27-SEP-18 01.02.21.150000 PM


but after that, it is snappy

SQL> create table t
  2   ( submitted timestamp,
  3     started   timestamp );

Table created.

SQL>
SQL> create or replace
  2  procedure prc is
  3  begin
  4    update t set started = systimestamp;
  5    commit;
  6  end;
  7  /

Procedure created.

SQL>
SQL> declare
  2    j int;
  3  begin
  4    dbms_job.submit( j,'prc;');
  5    insert into t(submitted) values (systimestamp);
  6    commit;
  7  end;
  8  /

PL/SQL procedure successfully completed.

SQL>
SQL> select * from t;

SUBMITTED
------------------------------------------------------------
STARTED
------------------------------------------------------------
27-SEP-18 01.03.25.529000 PM



SQL> /

SUBMITTED
------------------------------------------------------------
STARTED
------------------------------------------------------------
27-SEP-18 01.03.25.529000 PM
27-SEP-18 01.03.26.146000 PM


Having said that, delays like that have been seen across versions in the past, typically due to issues with the job coordinator process - so I'd raise a Support call.


Rating

  (4 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

A reader, September 27, 2018 - 6:13 am UTC

Hi,

It nevers start. As I said yesterday, all the jobs that I try to run appears in the table user_jobs.

So, the only solution is contact with the support?

Thanks!
Regards.
Connor McDonald
September 30, 2018 - 7:24 am UTC

On some platforms, setting job queue processes to 0 and then back to its previous value can "wake up" the coordinator as a workaround, but yes - you need to speak with Support, because that is not correct behaviour

DBMS_JOB.SUBMIT doesn't do anything in Oracle 12c (12.2.0.1.0)\

Cherif, September 27, 2018 - 9:57 am UTC

Hi all,
This seems to be introduced on 12.1.0.2( may 12.1.0.1).
I have same behavior as Connor under version 12.1.0.2 and 12.2.0.1. ( more than 45 seconds to start). This is not the under 11.2.0.4 ( less than 1 sec)

Thanks,
Cherif.


Sergio, October 01, 2018 - 6:15 am UTC

Hi everyone,

I found the solution.

The problem is that in the version 12c the mutithread isn't enabled.

So, this way, you must enabled manually following the steps of this link:

https://oracle-base.com/articles/12c/multithreaded-model-using-threaded_execution_12cr1

Once activated the jobs start without problem :)

Regards.
Connor McDonald
October 02, 2018 - 6:48 am UTC

Those two elements should not be related. I would consider this a workaround but definitely not a solution.

Check the CDB

A. Olsen, May 28, 2020 - 5:15 pm UTC

In 12c and up, make sure that the CDB also has job queue processes to more than 0
Connor McDonald
May 30, 2020 - 7:43 am UTC

Good point

More to Explore

Scheduler

All of the database utilities including the Scheduler are explained in the Utilities guide.