Oracle 后台进程(六)PMON进程
一、PMON简介
二、PMON的工作内容如下:
1、监控后台进程运行状况
2、如果某些进程异常中断,PMON去释放会话资源以及占用的锁LOCK
3、更新事务表的标志以及清除事务XID的标记
4、清除异常中断会话在BUFFER CACHE占用的缓存
5、PMON也负责定期把数据库实例注册到监听器中
三、
我们在学习Oracle基础知识的时候肯定了解过PMON后台进程的功能,包括轮训其他ORACLE PROCESS,清理cleanup dead process并释放锁release enqueue lock ,及清理cleanup latch。
虽然这些理论在你耳边萦绕了千百回, 但你是否有亲眼见证过一次Pmon cleanup dead process并release lock呢?大多数人可能没有。
微观Oracle=> MicroOracle, Maclean带领你见证微观视角下的Oracle behavior:
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
SQL> select * from global_name;
GLOBAL_NAME
--------------------------------------------------------------------------------
www.askmaclean.com
SQL> select pid,program from v$process;
PID PROGRAM
---------- ------------------------------------------------
1 PSEUDO
2 oracle@vrh1.oracle.com (PMON)
3 oracle@vrh1.oracle.com (PSP0)
4 oracle@vrh1.oracle.com (VKTM)
5 oracle@vrh1.oracle.com (GEN0)
6 oracle@vrh1.oracle.com (DIAG)
7 oracle@vrh1.oracle.com (DBRM)
8 oracle@vrh1.oracle.com (PING)
9 oracle@vrh1.oracle.com (ACMS)
10 oracle@vrh1.oracle.com (DIA0)
11 oracle@vrh1.oracle.com (LMON)
12 oracle@vrh1.oracle.com (LMD0)
13 oracle@vrh1.oracle.com (LMS0)
14 oracle@vrh1.oracle.com (RMS0)
15 oracle@vrh1.oracle.com (LMHB)
16 oracle@vrh1.oracle.com (MMAN)
17 oracle@vrh1.oracle.com (DBW0)
18 oracle@vrh1.oracle.com (LGWR)
19 oracle@vrh1.oracle.com (CKPT)
20 oracle@vrh1.oracle.com (SMON)
21 oracle@vrh1.oracle.com (RECO)
22 oracle@vrh1.oracle.com (RBAL)
23 oracle@vrh1.oracle.com (ASMB)
24 oracle@vrh1.oracle.com (MMON)
25 oracle@vrh1.oracle.com (MMNL)
26 oracle@vrh1.oracle.com (MARK)
27 oracle@vrh1.oracle.com (D000)
28 oracle@vrh1.oracle.com (SMCO)
29 oracle@vrh1.oracle.com (S000)
30 oracle@vrh1.oracle.com (LCK0)
31 oracle@vrh1.oracle.com (RSMN)
32 oracle@vrh1.oracle.com (TNS V1-V3)
33 oracle@vrh1.oracle.com (W000)
34 oracle@vrh1.oracle.com (TNS V1-V3)
35 oracle@vrh1.oracle.com (TNS V1-V3)
37 oracle@vrh1.oracle.com (ARC0)
38 oracle@vrh1.oracle.com (ARC1)
40 oracle@vrh1.oracle.com (ARC2)
41 oracle@vrh1.oracle.com (ARC3)
43 oracle@vrh1.oracle.com (GTX0)
44 oracle@vrh1.oracle.com (RCBG)
46 oracle@vrh1.oracle.com (QMNC)
47 oracle@vrh1.oracle.com (TNS V1-V3)
48 oracle@vrh1.oracle.com (TNS V1-V3)
49 oracle@vrh1.oracle.com (Q000)
50 oracle@vrh1.oracle.com (Q001)
51 oracle@vrh1.oracle.com (GCR0)
SQL> drop table maclean;
Table dropped.
SQL> create table maclean(t1 int);
Table created.
SQL> insert into maclean values(1);
1 row created.
SQL> commit;
Commit complete.
以上构建了示例环境, 可以看到在该实例中:
PID=2 PMON
PID=11 LMON
PID=18 LGWR
PID=20 SMON
PID=12 LMD
我们尝试构造2个存在”enq: TX – row lock contention”冲突的事务,之后使KILL掉第一个事务,这会导致需要PMON来recover dead process并release TX lock:
PROCESS A:
QL> select addr,spid,pid from v$process where addr = ( select paddr from v$session where sid=(select distinct sid from v$mystat));
ADDR SPID PID
---------------- ------------------------ ----------
00000000BD516B80 17880 46
SQL> select distinct sid from v$mystat;
SID
----------
22
SQL> update maclean set t1=t1+1;
1 row updated.
PROCESS B
SQL> select addr,spid,pid from v$process where addr = ( select paddr from v$session where sid=(select distinct sid from v$mystat));
ADDR SPID PID
---------------- ------------------------ ----------
00000000BD515AD0 17908 45
SQL> update maclean set t1=t1+1;
HANG..............
PROCESS B 因为"enq: TX – row lock contention"而HANG住
我们使用PROCESS C启用 对SMON的10500 event trace 和对PMON的KST TRACE:
SQL> set linesize 200 pagesize 1400
SQL> select * from v$lock where sid=22;
ADDR KADDR SID TY ID1 ID2 LMODE REQUEST CTIME BLOCK
---------------- ---------------- ---------- -- ---------- ---------- ---------- ---------- ---------- ----------
00000000BDCD7618 00000000BDCD7670 22 AE 100 0 4 0 48 2
00007F63268A9E28 00007F63268A9E88 22 TM 77902 0 3 0 32 2
00000000B9BB4950 00000000B9BB49C8 22 TX 458765 892 6 0 32 1
PROCESS A holde的ENQUEUE LOCK有三个 AE、TM、TX
SQL> alter system switch logfile;
System altered.
SQL> alter system checkpoint;
System altered.
SQL> alter system flush buffer_cache;
System altered.
SQL> alter system set "_trace_events"='10000-10999:255:2,20,33';
System altered.
SQL> ! kill -9 17880
KILL PROCESS A 并等待PROCESS B完成update
对PMON 和 PROCESS B 做errorstack 将KST TRACE记录到磁盘
SQL> oradebug setorapid 2;
Oracle pid: 2, Unix process pid: 17533, image: oracle@vrh1.oracle.com (PMON)
SQL> oradebug dump errorstack 4;
Statement processed.
SQL> oradebug tracefile_name
/s01/orabase/diag/rdbms/vprod/VPROD1/trace/VPROD1_pmon_17533.trc
SQL> oradebug setorapid 45;
Oracle pid: 45, Unix process pid: 17908, image: oracle@vrh1.oracle.com (TNS V1-V3)
SQL> oradebug dump errorstack 4;
Statement processed.
SQL>oradebug tracefile_name
/s01/orabase/diag/rdbms/vprod/VPROD1/trace/VPROD1_ora_17908.trc
分析PMON的 KST TRACE:
2012-05-18 10:37:34.557225 :8001ECE8:db_trace:ktur.c@5692:ktugru(): [10444:2:1] next rollback uba: 0x00000000.0000.00
2012-05-18 10:37:34.557382 :8001ECE9:db_trace:ksl2.c@16009:ksl_update_post_stats(): [10005:2:1] KSL POST SENT postee=18 num=4 loc='ksa2.h LINE:285 ID:ksasnd' id1=0 id2=0 name= type=0
2012-05-18 10:37:34.557514 :8001ECEA:db_trace:ksq.c@8540:ksqrcli(): [10704:2:1] ksqrcl: release TX-0007000d-0000037c mode=X
2012-05-18 10:37:34.558819 :8001ECF0:db_trace:ksl2.c@16009:ksl_update_post_stats(): [10005:2:1] KSL POST SENT postee=45 num=5 loc='kji.h LINE:3418 ID:kjata: wake up enqueue owner' id1=0 id2=0 name= type=0
2012-05-18 10:37:34.559047 :8001ECF8:db_trace:ksl2.c@16009:ksl_update_post_stats(): [10005:2:1] KSL POST SENT postee=12 num=6 loc='kjm.h LINE:1224 ID:kjmpost: post lmd' id1=0 id2=0 name= type=0
2012-05-18 10:37:34.559271 :8001ECFC:db_trace:ksq.c@8826:ksqrcli(): [10704:2:1] ksqrcl: SUCCESS
2012-05-18 10:37:34.559291 :8001ECFD:db_trace:ktu.c@8652:ktudnx(): [10813:2:1] ktudnx: dec cnt xid:7.13.892 nax:0 nbx:0
2012-05-18 10:37:34.559301 :8001ECFE:db_trace:ktur.c@3198:ktuabt(): [10444:2:1] ABORT TRANSACTION - xid: 0x0007.00d.0000037c
2012-05-18 10:37:34.559327 :8001ECFF:db_trace:ksq.c@8540:ksqrcli(): [10704:2:1] ksqrcl: release TM-0001304e-00000000 mode=SX
2012-05-18 10:37:34.559365 :8001ED00:db_trace:ksq.c@8826:ksqrcli(): [10704:2:1] ksqrcl: SUCCESS
2012-05-18 10:37:34.559908 :8001ED01:db_trace:ksq.c@8540:ksqrcli(): [10704:2:1] ksqrcl: release AE-00000064-00000000 mode=S
2012-05-18 10:37:34.559982 :8001ED02:db_trace:ksq.c@8826:ksqrcli(): [10704:2:1] ksqrcl: SUCCESS
2012-05-18 10:37:34.560217 :8001ED03:db_trace:ksfd.c@15379:ksfdfods(): [10298:2:1] ksfdfods:fob=0xbab87b48 aiopend=0
2012-05-18 10:37:34.560336 :GSIPC:kjcs.c@4876:kjcsombdi(): GSIPC:SOD: 0xbc79e0c8 action 3 state 0 chunk (nil) regq 0xbc79e108 batq 0xbc79e118
2012-05-18 10:37:34.560357 :GSIPC:kjcs.c@5293:kjcsombdi(): GSIPC:SOD: exit cleanup for 0xbc79e0c8 rc: 1, loc: 0x303
2012-05-18 10:37:34.560375 :8001ED04:db_trace:kss.c@1414:kssdch(): [10809:2:1] kssdch(0xbd516b80 = process, 3) 1 0 exit
2012-05-18 10:37:34.560939 :8001ED06:db_trace:kmm.c@10578:kmmlrl(): [10257:2:1] KMMLRL: Entering: flg(0x0) rflg(0x4)
2012-05-18 10:37:34.561091 :8001ED07:db_trace:kmm.c@10472:kmmlrl_process_events(): [10257:2:1] KMMLRL: Events: succ(3) wait(0) fail(0)
2012-05-18 10:37:34.561100 :8001ED08:db_trace:kmm.c@11279:kmmlrl(): [10257:2:1] KMMLRL: Reg/update: flg(0x0) rflg(0x4)
2012-05-18 10:37:34.563325 :8001ED0B:db_trace:kmm.c@12511:kmmlrl(): [10257:2:1] KMMLRL: Update: ret(0)
2012-05-18 10:37:34.563335 :8001ED0C:db_trace:kmm.c@12768:kmmlrl(): [10257:2:1] KMMLRL: Exiting: flg(0x0) rflg(0x4)
2012-05-18 10:37:34.563354 :8001ED0D:db_trace:ksl2.c@2598:kslwtbctx(): [10005:2:1] KSL WAIT BEG [pmon timer] 300/0x12c 0/0x0 0/0x0 wait_id=78 seq_num=79 snap_id=1
PMON发现dead process A后首先释放了其手上的TX Lock:
ksqrcl: release TX-0007000d-0000037c mode=X
接着它异步Post Process B,告诉Process B 你acquire的TX lock已经被我释放了:
KSL POST SENT postee=45 num=5 loc=’kji.h LINE:3418 ID:kjata: wake up enqueue owner’ id1=0 id2=0 name= type=0
Process B在收到PMON通知后立即继续了工作
ksl2.c@14563:ksliwat(): [10005:45:151] KSL POST RCVD poster=2 num=5 loc=’kji.h LINE:3418 ID:kjata: wake up enqueue owner’ id1=0 id2=0 name= type=0 fac#=3 posted=0x3 may_be_posted=1
kslwtbctx(): [10005:45:151] KSL WAIT BEG [latch: ges resource hash list] 3162668560/0xbc827e10 91/0x5b 0/0x0 wait_id=14 seq_num=15 snap_id=1
kslwtectx(): [10005:45:151] KSL WAIT END [latch: ges resource hash list] 3162668560/0xbc827e10 91/0x5b 0/0x0 wait_id=14 seq_num=15 snap_id=1
在RAC中它还会POST LMD(lock Manager)进程,通知其改变相关的GES信息:
2012-05-18 10:37:34.559047 :8001ECF8:db_trace:ksl2.c@16009:ksl_update_post_stats(): [10005:2:1] KSL POST SENT postee=12 num=6 loc=’kjm.h LINE:1224 ID:kjmpost: post lmd’ id1=0 id2=0 name= type=0
之后ksqrcl: release TX的工作才真正成功:
ksq.c@8826:ksqrcli(): [10704:2:1] ksqrcl: SUCCESS
之后PMON abort Process A原有的Transaction
2012-05-18 10:37:34.559291 :8001ECFD:db_trace:ktu.c@8652:ktudnx(): [10813:2:1] ktudnx: dec cnt xid:7.13.892 nax:0 nbx:0
2012-05-18 10:37:34.559301 :8001ECFE:db_trace:ktur.c@3198:ktuabt(): [10444:2:1] ABORT TRANSACTION – xid: 0x0007.00d.0000037c
释放Process A原本持有的maclean表的TM lock:
ksq.c@8540:ksqrcli(): [10704:2:1] ksqrcl: release TM-0001304e-00000000 mode=SX
ksq.c@8826:ksqrcli(): [10704:2:1] ksqrcl: SUCCESS
释放Process A原本持有的AE ( Prevent Dropping an edition in use) lock:
ksq.c@8540:ksqrcli(): [10704:2:1] ksqrcl: release AE-00000064-00000000 mode=S
ksq.c@8826:ksqrcli(): [10704:2:1] ksqrcl: SUCCESS
清理cleanup process A
kjcs.c@4876:kjcsombdi(): GSIPC:SOD: 0xbc79e0c8 action 3 state 0 chunk (nil) regq 0xbc79e108 batq 0xbc79e118
GSIPC:kjcs.c@5293:kjcsombdi(): GSIPC:SOD: exit cleanup for 0xbc79e0c8 rc: 1, loc: 0x303
kss.c@1414:kssdch(): [10809:2:1] kssdch(0xbd516b80 = process, 3) 1 0 exit
0xbd516b80是原PROCESS A 的paddr 起始地址
kssdch函数的主要作用是 删除process相关的state object SO KSS: delete children of state obj.
PMON 调用kmmlrl()函数更新instance goodness统计update for session drop delta
kmmlrl(): [10257:2:1] KMMLRL: Entering: flg(0x0) rflg(0x4)
kmmlrl_process_events(): [10257:2:1] KMMLRL: Events: succ(3) wait(0) fail(0)
kmmlrl(): [10257:2:1] KMMLRL: Reg/update: flg(0x0) rflg(0x4)
kmmlrl(): [10257:2:1] KMMLRL: Update: ret(0)
kmmlrl(): [10257:2:1] KMMLRL: Exiting: flg(0x0) rflg(0x4)
完成手头的工作后PMON再次进入 3s一次的”pmon timer”等待
kslwtbctx(): [10005:2:1] KSL WAIT BEG [pmon timer] 300/0x12c 0/0x0 0/0x0 wait_id=78 seq_num=79 snap_id=1
Filed Under: Oracle, Oracle Internal Research内部原理研究 Tagged With: kssdch, KST, pmon
Oracle 后台进程(六)PMON进程的更多相关文章
- Oracle 后台进程 详细说明
一. 进程概述 先来看一下Oracle 11g 的架构图. 看起来比较模糊,我已经上传到了csdn 的下载. 是个pdf 文件, 2m 多. 那个看起来比较清楚. 也对每个进程做了解释. 下载地址:O ...
- Oracle 后台进程(五)SMON进程
转载自:刘相兵 Maclean Liu 文章 你所不知道的后台进程 SMON 功能 SMON(system monitor process)系统监控后台进程,有时候也被叫做 system clea ...
- Oracle 后台进程(二)DBWR进程
一.DBWR进程介绍 DBWR进程执行将数据块缓冲区写入数据文件的工作,是负责缓冲存储管理的一个Oracle后台进程.在修改DB Cache中的某个缓冲区时,会将它标志为“DIRTY”,DBWR的主要 ...
- Oracle 后台进程(四)CKPT进程
一.CKPT简介 检查点是一个数据库事件,它把修改数据从高速缓存写入磁盘,并更新控制文件和数据文件.检查点分为三类:1)局部检查点:单个实例执行数据库所有数据文件的一个检查点操作,属于此实例的全部脏缓 ...
- 【ora10,4】oracle后台进程介绍:
一.SMON(System MONitor) 系统监控进程: 在数据库启动过程中,SMON排在CKPT进程之后,在Oracle9i中排在第六号的位置: PMON started with p ...
- oracle后台进程详解
oracle后台进程伴随实例的启动而启动,他们主要是维护数据库的稳定,相当于一个企业中的管理者及内部服务人员.他们并不会直接给用户提供服务. 一:database write--数据写入 DBW ...
- Oracle后台进程
后台进程简介 启动例程时,Oracle不仅会分配SGA,还会启动后台进程:关闭例程时,Oracle不仅会释放SGA所占用的内存空间,而且还会释放后台进程所占用的Cpu和内存资源.Oracle提供了很多 ...
- Oracle 后台进程介绍
一 进程分类: 1.服务器进程(server process): 依据客户请求完毕工作.如接收和处理应用发送的SQL语句 2.后台进程(background process): 随数据库而启动,用于完 ...
- Oracle 后台进程(一)简介
一.什么是Oracle数据库后台进程 为了时系统性能最好并能够协调多个用户,多进程系统使用了一些附加进程,成为后台进程. 在许多操作系统中,后台进程是在实例启动时自动建立的.一个Oracle实例可以包 ...
- SMON进程、PMON进程、LGWR/ARCH
SMON 进程:system monitor instance monitor 系统监控.实例监控进程 说明及作用:在实例关闭时,会清理临时段,整理空闲空间free space; 实例非正常关闭后,启 ...
随机推荐
- jenkinsFile harbor docker优化版
node { //study-center def mvnHome = tool name: 'maven', type: 'maven' REGISTRY = "192.168.22.27 ...
- Oracle查询部门工资最高员工的两种方法 1、MAX()函数 2、RANK()函数
本文以SCOTT用户下初始的EMP表为参考.代码可直接使用. 查询EMP表结构的语句如下,[代码1]: DESC EMP; EMP表结构如下:[结果1]: SQL> DESC EMP ...
- JS 02 函数
函数 一.创建函数 1.function 函数名( 形参列表 ){ 函数体 } 2.var 函数名 = function( 形参列表 ) { 函数体 } 3.var 函数名 = new Functio ...
- poj 2406 求最短重复字串
题解: KMP中next数组的巧妙运用.在这里我们假设这个字符串的长度是len,那么如果len可以被len-next[len]整除的话,我们就可以说len-next[len]就是那个最短子串的长度为什 ...
- 工欲善其事必先利其器之Vagrant + VirtualBox
Vagrant 可以管理 VirtualBox,实现快速配置创建虚拟机 1.下载软件 VirtualBox虚拟机下载地址:https://www.virtualbox.org/wiki/Downloa ...
- 【前端】安装wampserver提示丢失MSVCR100.dll的解决方法
先装Visual C++,再装wampserver 下载的时候请注意选择对应的32bit还是64bit的.然后安装. 再安装wamp
- 【web】Chrome 浏览器中查看 webSocket 连接信息
1.以下代码实现一个webSocket连接,在文本输入框中输入内容,点击发送,通过服务器,返回相同的内容显示在下方. 1 <!DOCTYPE html> 2 <html lang=& ...
- 漏洞预警 | ThinkPHP 5.x远程命令执行漏洞
ThinkPHP采用面向对象的开发结构和MVC模式,融合了Struts的思想和TagLib(标签库).RoR的ORM映射和ActiveRecord模式,是一款兼容性高.部署简单的轻量级国产PHP开发框 ...
- spring.factories配置文件的工厂模式
在springboot的各个依赖包下,我们经常看到META-INF/spring.factories这个文件.spring.factories文件的内容基本上都是这样的格式: # Initialize ...
- nohub
nohup command > myout.file 2>&1 & nohup command > /dev/null 2>&1 &