Oracle 10g: Checklist To Diagnose Issues Related To Automatic Run Of Job GATHER_STATS_JOB (Doc ID 803191.1)
In this Document
APPLIES TO:Oracle Database - Enterprise Edition - Version 10.2.0.1 to 10.2.0.5.0 [Release 10.2]Information in this document applies to any platform. Checked for relevance on 19-Nov-2010 GOALHow to diagnose the issues where GATHER_STATS_JOB job is not running automatically in the maintenance windows. (WEEKEND_WINDOW, WEEKNIGHT_WINDOW) SOLUTIONData Collection:
set markup html on spool on
spool job_diag.html SET echo on SELECT object_id, object_name FROM DBA_OBJECTS WHERE object_type = 'JOB'; SELECT owner,job_name,job_creator,schedule_owner,schedule_name,schedule_type, start_date,end_date,job_class,enabled,auto_drop,restartable,state,run_count, retry_count,last_start_date,last_run_duration,last_run_duration,next_run_date,logging_level FROM DBA_SCHEDULER_JOBS WHERE job_name ='GATHER_STATS_JOB'; SELECT * FROM DBA_SCHEDULER_JOB_LOG WHERE job_name ='GATHER_STATS_JOB' ORDER BY log_date DESC; SELECT * FROM DBA_SCHEDULER_JOB_RUN_DETAILS WHERE job_name ='GATHER_STATS_JOB' ORDER BY log_date DESC; SELECT * FROM DBA_SCHEDULER_WINDOWS; SELECT * FROM DBA_SCHEDULER_WINGROUP_MEMBERS; SELECT SYSTIMESTAMP FROM dual; SELECT dbms_scheduler.stime FROM dual ; show parameter STATISTICS_LEVEL; spool off set markup html off spool on
Please note that since it collects output in html format , the on screen output may not be readable. So please execute the complete script and review the job_diag.html file.
Step by Step Checklist1. Check if the GATHER_STATS_JOB exists in the database:
SELECT object_id, object_name FROM dba_objects WHERE object_type = 'JOB';
OBJECT_ID OBJECT_NAME
..... ................ 54901 GATHER_STATS_JOB ..... ................
conn as sysdba
@ $ORACLE_HOME/rdbms/admin/catnomwn.sql @ $ORACLE_HOME/rdbms/admin/catmwin.sql exec dbms_scheduler.add_window_group_member('MAINTENANCE_WINDOW_GROUP', 'WEEKNIGHT_WINDOW'); exec dbms_scheduler.add_window_group_member('MAINTENANCE_WINDOW_GROUP','WEEKEND_WINDOW'); (Though above two statements are included in catmwin script but they are needed because of the reason given in check 6.) 2. Check the properties of the job GATHER_STATS_JOB:SELECT owner, job_name, job_creator, schedule_owner, schedule_name, schedule_type, start_date, end_date, job_class, enabled, auto_drop, restartable, state,run_count, retry_count, last_start_date, last_run_duration, last_run_duration, next_run_date, logging_level FROM dba_scheduler_jobs WHERE job_name ='GATHER_STATS_JOB'; 3. Check the log details from the following query:SQL> SELECT * from DBA_SCHEDULER_JOB_LOG where job_name ='GATHER_STATS_JOB'; 4. Check the run details from the following query:SQL> select * from DBA_SCHEDULER_JOB_RUN_DETAILS where job_name ='GATHER_STATS_JOB'; 5. Check the status of the scheduler windows:select * from dba_scheduler_windows ; 6. Check if the WINDOWS are part of MAINTENANCE_WINDOW_GROUPSQL> SELECT * FROM DBA_SCHEDULER_WINGROUP_MEMBERS;
exec dbms_scheduler.add_window_group_member('MAINTENANCE_WINDOW_GROUP', 'WEEKNIGHT_WINDOW');
exec dbms_scheduler.add_window_group_member('MAINTENANCE_WINDOW_GROUP','WEEKEND_WINDOW');
catnomwn.sql
=========== ........... ........... execute dbms_scheduler.drop_window_group('MAINTENANCE_WINDOW_GROUP'); ........... ...........
catmwin.sql
========== BEGIN BEGIN dbms_scheduler.create_window_group('MAINTENANCE_WINDOW_GROUP'); dbms_scheduler.add_window_group_member('MAINTENANCE_WINDOW_GROUP', 'WEEKNIGHT_WINDOW'); dbms_scheduler.add_window_group_member('MAINTENANCE_WINDOW_GROUP', 'WEEKEND_WINDOW'); EXCEPTION when others then if sqlcode = -27477 then NULL; else raise; end if; END; dbms_scheduler.set_attribute('MAINTENANCE_WINDOW_GROUP','SYSTEM',TRUE); EXCEPTION when others then if sqlcode = -27477 then NULL; else raise; end if; END; /
7. Check STATISTICS_LEVEL parameter:To run the 'GATHER_STATS_JOB' it is essential that the STATISTICS_LEVEL initialization parameter is set to at least TYPICAL. 8. Check for other equal or higher priority overlapping WINDOWS:> If there is any other window with equal or higher priority already running then these windows will not be ACTIVE. 9. Manually open the WINDOW (only for NON PRODUCTION databases):Please note that check 9 should be performed only if it is a test database. Since enabling a WINDOW at the wrong time may create a huge load on the database, since all the JOBS associated with this WINDOW will start executing. 10. Recreate the GATHER_STATS_JOB and WINDOWS:Please note that following this step will drop and recreate GATHER_STATS_JOB and WEEKEND_WINDOWS and WEEKNIGHT_WINDOWS. If you had made any changes to these window timings according to your business requirement, then you need to do those changes again. 11. Restart the database if possible:If after confirming all the above checks if the job is still not running as expected, then sometimes restarting the database may be helpful to resolve the issue. |