常見的library cache lock產(chǎn)生的原因是什么,相信很多沒有經(jīng)驗的人對此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個問題。
創(chuàng)新互聯(lián)公司是一家專注網(wǎng)站建設(shè)、網(wǎng)絡(luò)營銷策劃、重慶小程序開發(fā)、電子商務(wù)建設(shè)、網(wǎng)絡(luò)推廣、移動互聯(lián)開發(fā)、研究、服務(wù)為一體的技術(shù)型公司。公司成立十年以來,已經(jīng)為上1000家辦公空間設(shè)計各業(yè)的企業(yè)公司提供互聯(lián)網(wǎng)服務(wù)?,F(xiàn)在,服務(wù)的上1000家客戶與我們一路同行,見證我們的成長;未來,我們一起分享成功的喜悅。
Troubleshooting Library Cache: Lock, Pin and Load Lock (Doc ID 444560.1)
一般可以理解的是alter table或者alter package/procedure會以X模式持有l(wèi)ibrary cache lock,造成阻塞。
但是常見的問題還有以下幾種原因:
1)錯誤的用戶名密碼:
一般需要通過ASH或者SSD/hang analyze去獲取p3進(jìn)行namespace分析。
1. event: 'library cache lock'
time waited: 43 min 12 sec
wait id: 9 p1: 'handle address'=0x7000003117dfca0
p2: 'lock address'=0x700000310866c80
p3: '100*mode+namespace'=0x4f0003
* time between wait #1 and #2: 0.000164 sec
<=================p3: '100*mode+namespace'=0x4f0003
mode=3
namespace=4f
HEX: 4f =>DEC: 79
select * FROM V$DB_OBJECT_CACHE;
SQL> select distinct KGLHDNSP,KGLHDNSD from x$kglob;
KGLHDNSP KGLHDNSD
---------- ----------------------------------------------------------------
0 SQL AREA
4 INDEX
1 TABLE/PROCEDURE
3 TRIGGER
52 SCHEDULER EARLIEST START TIME
64 EDITION
69 DBLINK
2 BODY
10 QUEUE
79 ACCOUNT_STATUS
23 RULESET
24 RESOURCE MANAGER
73 SCHEMA
74 DBINSTANCE
51 SCHEDULER GLOBAL ATTRIBUTE
38 RULE EVALUATION CONTEXT
82 SQL AREA BUILD
75 SQL AREA STATS
5 CLUSTER
18 PUB SUB INTERNAL INFORMATION
<======79 ACCOUNT_STATUS
ACCOUNT_STATUS說明library cache lock是在account上,可能是用錯誤的用戶名密碼登錄,或者是當(dāng)時正有人alter user(這種幾率極低)。
可以通過以下SQL去確認(rèn)錯誤的用戶名密碼登錄:
select username,
os_username,
userhost,
client_id,
trunc(timestamp),
count(*) failed_logins
from dba_audit_trail
where returncode=1017 and --1017 is invalid username/password
timestamp < sysdate -7
group by username,os_username,userhost, client_id,trunc(timestamp);
Or run following sql:
SELECT "USERNAME", "OS_USERNAME", "USERHOST", "EXTENDED_TIMESTAMP",returncode FROM "SYS"."DBA_AUDIT_SESSION" WHERE returncode != 0;
當(dāng)然必須確保audit 打開,并且有audit CREATE SESSION動作
To turn on audit:
Alter system set audit_trail=DB scope=spfile;
restart DB
audit CREATE SESSION;
audit ALTER USER;
檢查:
show parameter audit_trail
select * from DBA_STMT_AUDIT_OPTS;
2)正在執(zhí)行搜集統(tǒng)計信息,這是大家往往會忽略的,一般會看last_ddl_time,卻忽略了last_analyzed,
檢查腳本如下:
比如EMP是遇到library cache lock中的表名:
select owner,object_name,object_type,to_char(last_ddl_time,'yyyy-mm-dd hh34:mi:ss') from dba_objects where object_name='EMP';
select table_name,to_char(last_analyzed,'yyyy-mm-dd hh34:mi:ss') from dba_tables where table_name='EMP';
也需要檢查所有dependency的對象,因為oracle對象是相互關(guān)聯(lián)的,一個對象失效會導(dǎo)致一串失效。
select owner,object_name,object_type,to_char(last_ddl_time,'yyyy-mm-dd hh34:mi:ss') ddl_time from dba_objects where object_name in
(
select p.name
from sys.obj$ d, sys.dependency$ dep, sys.obj$ p
where d.obj# = dep.d_obj# and p.obj# = dep.p_obj#
start with d.name='EMP'
connect by prior dep.p_obj#=dep.d_obj#)
order by ddl_time desc;
select table_name,to_char(last_analyzed,'yyyy-mm-dd hh34:mi:ss') from dba_tables where table_name in
(
select p.name
from sys.obj$ d, sys.dependency$ dep, sys.obj$ p
where d.obj# = dep.d_obj# and p.obj# = dep.p_obj#
start with d.name='EMP'
connect by prior dep.p_obj#=dep.d_obj#)
order by last_analyzed desc;
比較典型的一個用戶實例:
select to_char(last_analyzed,'yyyy-mm-dd hh34:mi:ss') from dba_tables where table_name='XXXXX';
--2014-11-25 16:52:50
<=============gathering statistics in the issue time
2014-11-25 16:52:52 16620 c34q5c8gf6kum library cache lock
2014-11-25 16:52:52 16643 c34q5c8gf6kum library cache lock
<======The issue starts from 16:52:52 while statistics was gathered at 16:52:50
3)錯誤的語句解析(failed parse)
這是通常很難注意到的一個問題,因為被解析的語句往往在AWR中找不到(因為沒有通過parse),要注意查看AWR中的“failed parse elapsed time”
Event Waits Time(s) Avg wait (ms) % DB time Wait Class
library cache lock 6,714,208 363,093 54 67.14 Concurrency
library cache: mutex X 11,977,886 99,050 8 18.31 Concurrency
DB CPU 38,971 7.21
db file sequential read 350,069 2,465 7 0.46 User I/O
log file sync 217,673 1,969 9 0.36 Commit
Statistic Name Time (s) % of DB Time
sql execute elapsed time 537,418.09 99.37
parse time elapsed 467,101.99 86.37
failed parse elapsed time 460,663.79 85.18 <===============failed parse elapsed time was high. That means the issue was caused by parse failed.
看完上述內(nèi)容,你們掌握常見的library cache lock產(chǎn)生的原因是什么的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!
文章標(biāo)題:常見的librarycachelock產(chǎn)生的原因是什么
當(dāng)前路徑:http://www.rwnh.cn/article24/jjecje.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、App開發(fā)、自適應(yīng)網(wǎng)站、Google、微信小程序、品牌網(wǎng)站設(shè)計
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)