sql Lock and unlock

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.

猜你喜欢

转载自lliu26.iteye.com/blog/1511371