|
1. ÀϹÝÀûÀ¸·Î ¾Æ·¡¿Í °°ÀÌ lock ¼¼¼ÇÀ» ã½À´Ï´Ù.
BISDev:/oracle/dba_script] cat lock1.sql
select a.sid, decode(a.type, 'MR', 'Media Recovery',
'RT', 'Redo Thread', 'UN', 'User Name', 'TX', 'Transaction',
'TM', 'DML', 'UL', 'PL/SQL User Lock', 'DX', 'Distributed Xaction',
'CF', 'Control File', 'IS', 'Instance State', 'FS', 'File Set',
'IR', 'Instance Recovery', 'ST', 'Disk Space Transaction',
'IR', 'Instance Recovery', 'ST', 'Disk Space Transaction',
'TS', 'Temp Segment', 'IV', 'Library Cache Invalidation',
'LS', 'Log Start or Switch', 'RW', 'Row Wait',
'SQ', 'Sequence Number', 'TE', 'Extend Table',
'TT', 'Temp Table', a.type) lock_type,
decode(a.lmode,
0, 'None', /* Mon Lock equivalent */
1, 'Null', /* N */
2, 'Row-S (SS)', /* L */
3, 'Row-X (SX)', /* R */
3, 'Row-X (SX)', /* R */
4, 'Share', /* S */
5, 'S/Row-X (SSX)', /* C */
6, 'Exclusive', /* X */
to_char(a.lmode)) mode_held,
decode(a.request,
0, 'None', /* Mon Lock equivalent */
1, 'Null', /* N */
2, 'Row-S (SS)', /* L */
3, 'Row-X (SX)', /* R */
4, 'Share', /* S */
5, 'S/Row-X (SSX)', /* C */
6, 'Exclusive', /* X */
to_char(a.request)) mode_requested,
to_char(a.id1) lock_id1, to_char(a.id2) lock_id2
from v$lock a
where (id1,id2) in
(select b.id1, b.id2 from v$lock b where b.id1=a.id1 and
b.id2=a.id2 and b.request>0);
2. À§ÀÇ 1¹ø¿¡¼ lockÀÌ °Ë»öÀÌ µÇÁö ¾ÊÀ» °æ¿ì ¾Æ·¡¿Í °°Àº ½ºÅ©¸³Æ®·Î È®ÀÎÇÕ´Ï´Ù.
BISDev:/oracle/dba_script] cat lock2.sql
set linesize 200
col username for a15
col object_owner for a15
col object for a15
col lockwait for a10
select b.username username, c.sid sid, c.owner object_owner,
c.object object, b.lockwait, a.sql_text SQL
from v$sqltext a, v$session b, v$access c
where a.address=b.sql_address and
a.hash_value=b.sql_hash_value and
b.sid = c.sid and c.owner != 'SYS';
3. ¸¶Áö¸·À¸·Î ¾Æ·¡ ½ºÅ©¸³Æ®µµ ½ÇÇàÇÕ´Ï´Ù.
BISDev:/oracle/dba_script] cat lock3.sql
select substr(s.username,1,11) "ORACLE USER",
p.pid "PROCESS ID", s.sid "SESSION ID", s.serial#,
osuser "OS USER", p.spid "PROC SPID",
s.process "SESS SPID", s.lockwait "LOCK WAIT"
from v$process p, v$session s, v$access a
where a.sid=s.sid and
p.addr=s.paddr and
s.username != 'SYS';
Áú¹® 1] 1¹ø ½ºÅ©¸³Æ®¸¦ ½ÇÇàÇÏ¸é µ¥ÀÌÅÍ°¡ ¾ø´õ¶óµµ 2,3¹ø ½ºÅ©¸³Æ®¸¦ ½ÇÇàÇÏ¸é ¸¹Àº µ¥ÀÌÅÍ°¡ °ËÃ⠵Ǵ °ÍÀº ¹«½¼ ÀÌÀ¯Àΰ¡¿ä? ±×¸®°í 2,3¹ø ½ºÅ©¸³Æ® ½ÇÇàÇÏ¿© °Ë»öµÈ °á°úÀÇ ¼¼¼ÇÀ» kill
½ÃÄѵµ µÇ´ÂÁö¿ä?
Áú¹® 2] ´Ù½Ã Á¾ÇÕÇÏÀÚ¸é lock¿¡ °É¸° ¼¼¼Ç°ú Å×À̺íÀ» ¾Ë¾Æº¸·Á¸é 1,2,3¹ø ½ºÅ©¸³Æ®¸¦ ½ÇÇàÇϴµ¥ °¢°¢ÀÇ Á¤È®ÇÑ ¿ëµµ¿Í Àǹ̸¦ ¾Ë°í ½Í½À´Ï´Ù.
ANSWER
=======
1. lock1.sqlÀº ´ÙÀ½ÀÇ url¿¡¼ Á¤ÀÇÇÑ system lock typeÀ» Áã°í , ´Ù¸¥ process°¡ request¸¦ ÇØ¾ß º¸¿©Áö´Â queryÀÔ´Ï´Ù.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/dynview
s_1147.htm#g1427852
Table 6-1 Values for the TYPE Column: System Types
lockÀ» Áã¾úÀ¸³ª , »ó±âÀÇ sqlÀ» ¼öÇà½Ã ¿äûÇÏ´Â process°¡ ¾ø¾ú´Ù¸é È®ÀεÇÁö ¾ÊÀ» °ÍÀÔ´Ï´Ù.
2,3¹ø ½ºÅ©¸³Æ®´Â ¿äûÇÏ´Â ´Ù¸¥ process°¡ ¾ø´õ¶óµµ oracle¿¡ Á¢¼ÓÇÏ¿© library cache¿¡ ´ëÇÑ access°¡ Àֱ⸸ Çϸé
º¸¿©Áö´Â scriptµé·Î ¸¹Àº Á¤»óÀûÀÎ sessionµéÀ» Æ÷ÇÔÇÕ´Ï´Ù.\
lockingÇö»óÀÌ ¹ß»ýÇÏ´Â °æ¿ì, ¾î¶°ÇÑ lockÀÎÁö ±×¸®°í ±× lockÀ» À¯¹ßÇÑ program layer¿¡ ¹®Á¦´Â ¾ø´ÂÁö µîÀÇ Á¡°ËÀÌ ÇÊ¿äÇÕ´Ï´Ù.
2. 1¹øÀº LOCK ¹®Á¦¸¦ ÀÏÀ¸Å°´Â SQL ¸í·É ã´Âµ¥ »ç¿ëÇÕ´Ï´Ù.
2¹øÀº Lock°ú °ü·ÃµÈ Å×À̺íÀ» , 3¹øÀº °ü·ÃµÈ ÇÁ·Î¼¼½º¸¦ È®ÀÎÇÕ´Ï´Ù.
°á·ÐÀûÀ¸·Î Á¤¸®½Ã ¸¶Áö¸· 3¹øÀÇ script¸¦ ¼öÇàÇÏ¿© lockwait ¿¡ ¾Æ¹«·± °ªÀÌ ¾ø´Â°Ô blockerÀÔ´Ï´Ù.
ÀÌ process°¡ ¿À·§µ¿¾È lockÀ» Áã°í ÀÖ´Ù¸é, client/server process°¡ ¸ðµÎ Á¤»óÀûÀÎÁö ¿©ºÎ¿¡ ´ëÇÑ È®Àι×
Á¤¸®°¡ ÇÊ¿äÇÒ ¼ö ÀÖ½À´Ï´Ù. ¶ÇÇÑ 2¹øÀ» ¼öÇàÇÏ¿© ¾î¶°ÇÑ tableÀÎÁö È®ÀÎ¹× ¾î¶°ÇÑ ÀÛ¾÷ÀÎÁö À¯Ãß·Î program layer¿¡ ¹®Á¦°¡
¾ø¾ú´ÂÁöµµ Á¡°ËÇØ¾ß ÇÕ´Ï´Ù.
´äº¯µå¸° »çÇ׿¡ ´ëÇÑ Ãß°¡ ¹®ÀÇ°¡ ÀÖÀ¸½Ã¸é update¸¦ ³²°Ü Áֽðí ÃæºÐÇϽøé close¹Ù¶ø´Ï´Ù.
|