国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > Oracle > 正文

Oracle診斷案例-Job任務停止執行[最終版]

2024-08-29 13:31:24
字體:
來源:轉載
供稿:網友

oracle診斷案例-job任務停止執行

last updated: friday, 2004-11-26 9:48 eygle
    
 


 

昨天接到研發人員報告,數據庫定時任務未正常執行,導致某些操作失敗。

開始介入處理該事故.
系統環境:
sunos db 5.8 generic_108528-21 sun4u sparc sunw,ultra-4
oracle9i enterprise edition release 9.2.0.3.0 - production

1.首先介入檢查數據庫任務

 

$ sqlplus "/ as sysdba"sql*plus: release 9.2.0.3.0 - production on wed nov 17 20:23:53 2004copyright (c) 1982, 2002, oracle corporation. all rights reserved.connected to:oracle9i enterprise edition release 9.2.0.3.0 - productionwith the partitioning, olap and oracle data mining optionsjserver release 9.2.0.3.0 - productionsql> select job,last_date,last_sec,next_date,next_sec,broken,failures from dba_jobs; job last_date last_sec next_date next_sec b failuresinterval---------- --------- ---------------- --------- ---------------- - ---------- ---------------------------- 31 16-nov-04 01:00:02 17-nov-04 01:00:00 n 0trunc(sysdate+1)+1/24 27 16-nov-04 00:00:04 17-nov-04 00:00:00 n 0trunc(sysdate) + 1 35 16-nov-04 01:00:02 17-nov-04 01:00:00 n 0trunc(sysdate+1)+1/24 29 16-nov-04 00:00:04 17-nov-04 00:00:00 n 0trunc(sysdate) + 1 30 01-nov-04 06:00:01 01-dec-04 06:00:00 n 0trunc(add_months(sysdate,1),'mm')+6/24 65 16-nov-04 04:00:03 17-nov-04 04:00:00 n 0trunc(sysdate+1)+4/24 46 16-nov-04 02:14:27 17-nov-04 02:14:27 n 0sysdate+1 66 16-nov-04 03:00:02 17-nov-04 18:14:49 n 0trunc(sysdate+1)+3/248 rows selected.

發現job任務是都沒有正常執行,最早一個應該在17-nov-04 01:00:00執行。但是沒有執行。

2.建立測試job

 

create or replace procedure pining isbegin null; end;/variable jobno number;variable instno number;begin select instance_number into :instno from v$instance; dbms_job.submit(:jobno, 'pining;', trunc(sysdate+1/288,'mi'), 'trunc(sysdate+1/288,''mi'')', true, :instno);end;/

發現同樣的,不執行。
但是通過dbms_job.run(<job>)執行沒有任何問題。

3.進行恢復嘗試

懷疑是cjq0進程失效,首先設置job_queue_processes為0,oracle會殺掉cjq0及相應job進程
sql> alter system set job_queue_processes = 0;

等2~3分鐘,重新設置

sql> alter system set job_queue_processes = 5;

此時pmon會重起cjq0進程

在警報日志中可以看到以下信息:

 

thu nov 18 11:59:50 2004alter system set job_queue_processes=0 scope=memory;thu nov 18 12:01:30 2004alter system set job_queue_processes=10 scope=memory;thu nov 18 12:01:30 2004restarting dead background process cjq0cjq0 started with pid=8

 

但是job仍然不執行,而且在再次修改的時候,cjq0直接死掉了。

 

thu nov 18 13:52:05 2004alter system set job_queue_processes=0 scope=memory;thu nov 18 14:09:30 2004alter system set job_queue_processes=10 scope=memory;thu nov 18 14:10:27 2004alter system set job_queue_processes=0 scope=memory;thu nov 18 14:10:42 2004alter system set job_queue_processes=10 scope=memory;thu nov 18 14:31:07 2004alter system set job_queue_processes=0 scope=memory;thu nov 18 14:40:14 2004alter system set job_queue_processes=10 scope=memory;thu nov 18 14:40:28 2004alter system set job_queue_processes=0 scope=memory;thu nov 18 14:40:33 2004alter system set job_queue_processes=1 scope=memory;thu nov 18 14:40:40 2004alter system set job_queue_processes=10 scope=memory;thu nov 18 15:00:42 2004alter system set job_queue_processes=0 scope=memory;thu nov 18 15:01:36 2004alter system set job_queue_processes=15 scope=memory;

4.嘗試重起數據庫
這個必須在晚上進行

 

pmon started with pid=2dbw0 started with pid=3lgwr started with pid=4ckpt started with pid=5smon started with pid=6reco started with pid=7cjq0 started with pid=8qmn0 started with pid=9....

cjq0正常啟動,但是job仍然不執行。

5.沒辦法了...

繼續研究...居然發現oralce有這樣一個bug

1. clear description of the problem encountered:
slgcsf() / slgcs() on solaris will stop incrementing after
497 days 2 hrs 28 mins (approx) machine uptime.


2. pertinent configuration information
no special configuration other than long machine uptime. .

3. indication of the frequency and predictability of the problem
100% but only after 497 days.

4. sequence of events leading to the problem
if the gethrtime() os call returns a value > 42949672950000000
nanoseconds then slgcs() stays at 0xffffffff. this can
cause some problems in parts of the code which rely on
slgcs() to keep moving.
eg: in kkjssrh() does "now = slgcs(&se)" and compares that
to a previous timestamp. after 497 days uptime slgcs()
keeps returning 0xffffffff so "now - kkjlsrt" will
always return 0. .

5. technical impact on the customer. include persistent after effects.
in this case dbms jobs stopped running after 497 days uptime.
other symptoms could occur in various places in the code.

好么,原來是計時器溢出了,一檢查我的主機:

bash-2.03$ uptime 10:00pm up 500 day(s), 14:57, 1 user, load average: 1.31, 1.09, 1.08bash-2.03$ datefri nov 19 22:00:14 cst 2004

 

剛好到事發時是497天多一點.ft.

6.安排重起主機系統..

這個問題夠郁悶的,nnd,誰曾想oracle這都成...

oracle最后聲稱:

fix made it into 9.2.0.6 patchset

在solaris上的9206尚未發布...暈.

好了,就當是個經歷吧,如果有問題非常不可思議的話,那么大膽懷疑oracle吧,是bug,可能就是bug。

重起以后問題解決,狀態如下:

$ sqlplus "/ as sysdba"sql*plus: release 9.2.0.3.0 - production on fri nov 26 09:21:21 2004copyright (c) 1982, 2002, oracle corporation. all rights reserved.connected to:oracle9i enterprise edition release 9.2.0.3.0 - productionwith the partitioning, olap and oracle data mining optionsjserver release 9.2.0.3.0 - productionsql> select job,last_date,last_sec,next_date,next_sec from user_jobs; job last_date last_sec next_date next_sec---------- --------- ---------------- --------- ---------------- 70 26-nov-04 09:21:04 26-nov-04 09:26:00sql> / job last_date last_sec next_date next_sec---------- --------- ---------------- --------- ---------------- 70 26-nov-04 09:26:01 26-nov-04 09:31:00sql> sql> select * from v$timer; hsecs---------- 3388153sql> select * from v$timer; hsecs---------- 3388319sql>

 

7.faq

一些朋友在pub上問的問題
q:對于不同平臺,是否存在同樣的問題?

a:對于不同平臺,存在同樣的問題
因為oracle使用了標準c函數gethrtime
參考:
http://www.eygle.com/unix/man.page.of.gethrtime.htm

使用了該函數的代碼都會存在問題.

在metalink note:3427424.8 文檔中,oracle定義的平臺影響為:generic (all / most platforms affected)

q.計數器溢出,看了看job 中基本都是1天左右執行一次,如果設置 3 天執行一次的 job , 是否出問題的uptime 應該是 497*3 之后呢 ?

a:不會

oracle內部通過計時器來增進相對時間.
由于oracle內部hrtime_t使用了32位計數

那么最大值也就是0xffffffff
0xffffffff = 4294967295

slgcs()是10億分之一秒,溢出在42949672950000000這個點上.

注意,這里0xffffffff,達到這個值時,本來是無符號整型,現在變成了-1,那么這個值遞增時,+1 = 0了。
時間就此停住了。

我寫了一小段代碼來驗證這個內容,參考:

 [[email protected] oracle]$ cat unsign.c#include int main(void){unsigned int num = 0xffffffff;printf("num is %d bits long/n", sizeof(num) * 8);printf("num = 0x%x/n", num);printf("num + 1 = 0x%x/n", num + 1);return 0;}[[email protected] oracle]$ gcc -o unsign.sh unsign.c[[email protected] oracle]$ ./unsign.shnum is 32 bits longnum = 0xffffffffnum + 1 = 0x0[[email protected] oracle]$

 


q:內部時鐘之一應該就是這個吧: v$timer 精確到1/100 秒的數據

沒錯!

注意前面說的:

4. sequence of events leading to the problem
if the gethrtime() os call returns a value > 42949672950000000
nanoseconds then slgcs() stays at 0xffffffff. this can
cause some problems in parts of the code which rely on
slgcs() to keep moving.

也就是說如果gethrtime() 操作系統調用返回值大于42949672950000000(單位10億分之一秒)

也就是說oracle將得到一個cs值為4294967295的時間值

而4294967295值就是0xffffffff

所以當時v$timer的計時也就是:

sql> select * from v$timer; hsecs----------4294967295sql> / hsecs----------4294967295sql> / hsecs----------4294967295sql>





 

本文作者:
eygle,oracle技術關注者,來自中國最大的oracle技術論壇itpub.
www.eygle.com是作者的個人站點.你可通過[email protected]來聯系作者.歡迎技術探討交流以及鏈接交換.

原文出處:

http://www.eygle.com/case/job.can.not.execute.auto.htm

 
  • 網站運營seo文章大全
  • 提供全面的站長運營經驗及seo技術!
  • 發表評論 共有條評論
    用戶名: 密碼:
    驗證碼: 匿名發表
    主站蜘蛛池模板: 泗洪县| 高州市| 怀远县| 南汇区| 铅山县| 清河县| 正安县| 清河县| 永新县| 蓝田县| 会宁县| 巴彦县| 长汀县| 山东省| 昌平区| 瑞丽市| 长汀县| 土默特右旗| 化州市| 黔东| 凤城市| 荔浦县| 乐都县| 历史| 瓦房店市| 蓝田县| 晋州市| 孟州市| 尼玛县| 平山县| 尼勒克县| 湘西| 五指山市| 中阳县| 贵定县| 洮南市| 来凤县| 米脂县| 呈贡县| 自贡市| 车险|