dbms_job, pended and drifting

Suppose we have a job submitted, interval is sysdate + 1 / 24 / 60, but the job is going to take 5 minutes, how will Oracle behave?
Looks like the sequence of events will be the following:
T0, Job #1 starts, the next run time is going to be sysdate(T0) + 1 minute.
T0 + 1 minute, The next job #2 starts, but is blocked by a QS lock, id2 in v$lock will tell the job id.
T0 + 5 minute, Job #1 completes, set sys.job$.next_date=greatest(T0 + 1/24/60, sysdate), effectively changing the this_date for job #2 to be sysdate. Job #2 starts.
Another issue is T0 is loosely guarenteed and could be off by couple of seconds, and even if the job completes within interval, the start time could drift if one uses sysdate only. To avoid drifting, use some calculation based on trunc(sysdate) instead of sysdate.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: