| Regarding row lock [message #647347] |
Tue, 26 January 2016 21:42  |
 |
gorants
Messages: 85 Registered: May 2014 Location: ATL
|
Member |
|
|
Hello experts,
I have question on regarding row lock, i have a query like below in my application code, it means it is locking the row? how long will it lock, the reason i am asking is i have scheduler which executes every 2 minutes, the next occurrence scheduler sometimes waiting for 1, 4 , 5 , 10 minutes randomly on query execution. the query execution is just select statement on LM_ID=123131 record.
select LM_IO from LMT where LM_ID=123131 FOR UPDATE NOWAIT;
How do i know because of locking if my query execution is waiting.
Appreciate your thoughts.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Re: Regarding row lock [message #647483 is a reply to message #647463] |
Fri, 29 January 2016 06:50   |
 |
EdStevens
Messages: 1377 Registered: September 2013
|
Senior Member |
|
|
gorants wrote on Thu, 28 January 2016 21:28if commit/rollback takes 30 minutes, until then session2 will wait or error out immediately? how do i know if there are any locks existed thats the reason session2 failed or waiting?
Please review the Concepts Manual (link provided by Michael), specifically the section on data concurrency.
If the only lock is session B waiting on the lock held by Session A, then the wait will be as long as it takes for A to release the lock via commit or rollback. But if in the course of events, B then acquires a lock on a resource that is then needed by A, then each session has a resource needed by the other and each is waiting on the other to release. this is known as a "deadly embrace", or a "deadlock". Eventually, the db will detect this and kill one of the transactions, allowing the other to complete. When this happens, a message to that effect is written to the alert log, and that message specifically states that it is an application error. And I just gave you two terms on which to do further reading.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|