Oracle dead lock deep research.
Update SQLS will lead dead lock exception. Because by default, it use optimistic lock but not pessimistic lock.
Below description is exceprted from the attachment(It exceeds my image that this blog can not upload the attachment,hehe)
Optimistic locking offers an elegant solution to the problems outlined above. Optimistic locking does
not lock records when they are read, and proceeds on the assumption that the data being updated has not
changed since the read. Since no locks are taken out during the read, it doesn’t matter if the user goes to
lunch after starting a transaction, and deadlocks are all but eliminated since users should never have to
wait on each other’s locks
There are some ways to resolve this problem.
1. Create a pessimistic lock. Change the sql like below formal.
First: select … from … for update nowait
Second: update the resultSet.
2. Execute the SQL again after a random duration when program meets this kind of exception. (It will consume lot of db server resource. I don't think it is the better way)
3. Schedule the SQL executed sequenced or split data without interfere.
Ïà¹ØÎĵµ£º
²éѯÐÇÆÚ¼¸:
select to_char(sysdate,'day') from dual;
²éѯ¼¸ºÅ:
select to_char(sysdate,'dd') from dual;
²éѯСʱÊý:
select to_char(sysdate,'hh24') from dual;
²éѯʱ¼ä:
select to_char(sysdate,'hh24:mi:ss') from dual;
²éѯÈÕÆÚʱ¼ä:
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
²é ......
³£¼ûºǫ́½ø³Ì°üÀ¨:
• Êý¾Ý¿âд½ø³Ì (DBWn):½«Êý¾Ý¿â»º³åÇø¸ßËÙ»º´æÖеľ¹ýÐ޸ĵĻº³åÇø(»ÒÊý¾Ý»º ³åÇø)ÒÔÒì²½·½Ê½Ð´Èë´ÅÅÌ
• ÈÕ־д½ø³Ì (LGWR):½«ÈÕÖ¾»º³åÇøÖгÆÎªÖØ×öÐÅÏ¢µÄ»Ö¸´ÐÅϢдÈë´ÅÅÌÉϵÄÖØ×öÈÕ Ö¾Îļþ
• ¼ì²éµã½ø³Ì (CKPT):ÔÚ¿ØÖÆÎļþºÍÿ¸öÊý¾ÝÎļþÍ·ÖмǼ¼ì²éµãÐÅÏ¢
• ϵͳ¼àÊÓÆ÷½ø³ ......
•ºÎΪÉó¼Æ
Êý¾Ý¿âÉ󼯣¬¾ÍÊǶÔÊý¾Ý¿âµÄ»î¶¯×ö¸ú×ټǼ£¬Ö÷Òª°üÀ¨Êý¾Ý¿âÁ¬½Ó£¬SQLÓï¾äÖ´ÐУ¬Êý¾Ý¿â¶ÔÏó·ÃÎÊÕâЩ·½ÃæµÄ¸ú×ټǼ¡£
•ÏÖʵ×÷ÓÃ
°²È«¿ØÖÆ¡¢¸ú×ÙÊý¾Ý±ä»¯¡¢³ÌÐòBUGµ÷ÊÔ¡¢×Ô¶¨ÒåµÄÊý¾Ý»ã×Ü·ÖÎö¡¢²Ù×÷ÈÕÖ¾
•´æ´¢·½Ê½
Ò»ÖÖÊÇ´æ´¢ÔÚ²Ù×÷ϵͳÎļþÖУ¬Ò»ÖÖÊÇ´æ´¢ÔÚsystem±í¿Õ¼äÖеÄSYS.AUD$±íÖÐ
......
•±í·ÖÇø¼¼ÊõÊÇÔÚ³¬´óÐÍÊý¾Ý¿â(VLDB)Öн«´ó±í¼°ÆäË÷Òýͨ¹ý·ÖÇø£¨patition£©µÄÐÎʽ·Ö¸îΪÈô¸É½ÏС¡¢¿É¹ÜÀíµÄС¿é£¬²¢ÇÒÿһ·ÖÇø¿É½øÒ»²½»®·ÖΪ¸üСµÄ×Ó·ÖÇø£¨sub partition£©
•ͨ¹ý¶Ô±í½øÐзÖÇø£¬¿ÉÒÔ»ñµÃÒÔϵĺô¦
–¼õÉÙÊý¾ÝË𻵵ĿÉÄÜÐÔ
–¸÷·ÖÇø¿ÉÒÔ¶ÀÁ¢±¸·ÝºÍ»Ö¸´£¬ÔöÇ¿ÁËÊý¾Ý¿âµÄ¿É¹ÜÀíÐÔ
......
/**
*
*/
package com.huawei.widget.util;
import java.math.BigDecimal;
/**
* @author tanjixuan
* @since 2008-12-20
*
*/
public final class DatabaseUtil
{
// oracleתÒå×Ö·û
public static final char ORACLE_ESCAPE_CHAR = '\\';
// orac ......