欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

sql Lock and unlock

程序员文章站 2024-01-23 20:52:04
...
Lock:
I had known how to lock the record of [name = 'hp_release_pwd'] and why it came out.
• When I tried to insert password which longer than 64 characters, it came out the PersistenceSessionException: Insert failed  Exception. At that time, the record had not been locked.
• And when I modified password again(all of the input is valid), this record would been locked.
• Then I found out which SQL led to this happened: there were three same SQL in one SQL_ID processed at the same time :
[Update svn_config Set      cfg_value = :1   Where name = 'hp_release_pwd'].

如图1
(On the other hand, this record was locked by these three same SQL, not related with
[begin dbms_application_info.set_module(:1,'Code Insight'); end;] )


Unlock:
• Firstly we need find out the locked session:
select event,osuser,sid,serial#, sql_id from v$session where username='ERS'

如图2
PS: SID and SERIAL# will be used when kill the session.
      SQL_ID is used to find out which SQL cause the record locked, as showed in above snapshot.
• Secondly we need kill the session which had been locked in DB:
alter system kill session '[SID],[SERIAL#]' immediate
• Finally we just need to restart the app. The locked record is unlocked.
  • sql Lock and unlock
            
    
    博客分类: experience sqllockunlock 
  • 大小: 48.2 KB
  • sql Lock and unlock
            
    
    博客分类: experience sqllockunlock 
  • 大小: 33.9 KB
相关标签: sql lock unlock