尝试并行运行多个作业时获取以下异常。这种情况会间歇性地发生。
失败点是DBMS_SCHEDULER.run_job
SQL Exception ORA-27478: job "JOB_MIG_17602" is running "ORA-06512: at "SYS.DBMS_ISCHED", line 196 ORA-06512: at "SYS.DBMS_SCHEDULER", line 48
工作描述:
作业调用更新表的存储过程。使用唯一作业名称创建的作业的不同实例调用相同的存储过程。
以下是运行作业的步骤:
DBMS_SCHEDULER.create_job(
job_name => l_job_name,
job_type => 'STORED_PROCEDURE',
job_action => i_chunk_processor_name,
number_of_arguments => 2,
enabled => FALSE,
auto_drop => FALSE
);
DBMS_SCHEDULER.set_job_argument_value(job_name => l_job_name, argument_position => 1, argument_value => i_user_id);
DBMS_SCHEDULER.set_job_argument_value(job_name => l_job_name, argument_position => 2, argument_value => i_chunk_id);
DBMS_SCHEDULER.enable(l_job_name);
COMMIT;
DBMS_SCHEDULER.run_job(job_name => l_job_name, use_current_session => FALSE);
答案 0 :(得分:0)
启用作业意味着它有资格执行。因此,如果调度程序协调员选择它并在之前启动它,那么您将进入" run_job"命令,然后你就会得到错误,例如
SQL> begin
2 DBMS_SCHEDULER.create_job(
3 job_name => 'XXX',
4 job_type => 'PLSQL_BLOCK',
5 job_action => 'begin dbms_lock.sleep(60); end;',
6 enabled => FALSE,
7 auto_drop => FALSE
8 );
9 end;
10 /
PL/SQL procedure successfully completed.
SQL> exec DBMS_SCHEDULER.enable('XXX');
PL/SQL procedure successfully completed.
-- I wait for a few seconds
--
SQL> exec DBMS_SCHEDULER.run_job(job_name => 'XXX', use_current_session => FALSE);
BEGIN DBMS_SCHEDULER.run_job(job_name => 'XXX', use_current_session => FALSE); END;
*
ERROR at line 1:
ORA-27478: job "MCDONAC"."XXX" is running
ORA-06512: at "SYS.DBMS_ISCHED", line 238
ORA-06512: at "SYS.DBMS_SCHEDULER", line 568
ORA-06512: at line 1
如果您启用它,则不需要显式的run_job请求。