.After the transaction is complete exclusive lock downgrades to which lock?
This sounds awfully like an exam question. Have you done any research yourself? Where have you looked? What have you found out?
[/collapse]
[collapse] From: balaji [mailto:bounce-balaji@community.progress.com]
Sent: Monday, April 14, 2014 1:57 AM
To: TU.OE.General@community.progress.com
Subject: transactionThread created by balaji.After the transaction is complete exclusive lock downgrades to which lock?Stop receiving emails on this subject.Flag this post as spam/abuse.
Release does not do what you think it does. Refinding with a no-lock also does not do what you think it does.
The key, here, is to scope the buffer the same as the transaction and then it is a non-issue. Everything else is self-deception.
[/collapse]
[collapse] From: James Palmer [mailto:bounce-jdpjamesp@community.progress.com]
Sent: Monday, April 14, 2014 9:38 AM
To: TU.OE.General@community.progress.com
Subject: RE: transactionReply by James PalmerRelease does not do what you think it does. Refinding with a no-lock also does not do what you think it does.
Stop receiving emails on this subject.Flag this post as spam/abuse.
As Thomas says, you need to scope your buffers correctly, and not fudge the locking. You will find you introduce bugs to the system that are hard to track down by using release and refind of records no-lock. If you explicitly find your records exclusive-lock within the scope of the transaction itself then there is no need to release as the locks will be released at the end of the transaction block. If you find yourself having to add release statements then your scoping is wrong. You will find you have unexpected behaviour when transactions roll back, and you may well find you get lock table overflows.
[/collapse]Reply by James PalmerRelease does not do what you think it does. Refinding with a no-lock also does not do what you think it does.
Stop receiving emails on this subject.Flag this post as spam/abuse.
Reply by James PalmerRelease does not do what you think it does. Refinding with a no-lock also does not do what you think it does.
Stop receiving emails on this subject.Flag this post as spam/abuse.
Flag this post as spam/abuse.
Click here to report this email as spam.
Steph, if you add for table to the do transaction, then you don't need to do any of the stuff afterwards. Better yet, put these actions in an IP or method, define a buffer in that IP or method, and the buffer use will be scoped to the IP or method. The first time you add in this kind of scoping, you are likely to get complaints from other places in the code and need to add it there. But, if you do this consistently, there is no ambiguity about locks and no possibility of mysterious interactions.
While having the tx and the buffers have the same scope is "safer", there is nothing wrong with raising the lock for an existing buffer, changing the data, and then issuing a "request" to lower the lock level on that buffer when the TX ends.
Steph - the problem about FIND CURRENT NO-LOCK and RELEASE that has been alluded to earlier is that notion that doing a FCNL or REL will downgrade the lock immediately. These statements do not change the current locking level until such time as the TX ends.
Finally, assertions that using FCNL and REL will cause "other problems" are unsupported fear-mongering. If they're used properly - which you appear to be doing - then they're perfectly fine as a programming practice.
From the OE ABL Essentials:
"If you have any doubt at all about when a record goes out of scope or when a lock is
released, release the record explicitly when you are done updating it with the RELEASE
statement."
I recommend you read "Handling Data and Locking Records", understand locking the best you can. Read it several times, create examples and take notes on the behavior. Do not fall into fear mongering.
Steph, sticking in a few FOR TABLE additions to control scope does not require rewriting the application, but does accomplish what a lot of fiddling with finds and releases does not. I have never seen a situation where I couldn't control scope to the benefit of the clarity of the program.
@steph:
the RELEASE statement is not for releasing locks. it is for releasing /buffers/. it causes the specified buffer to be cleared so that it contains nothing. if necessary, its contents will first be sent to the database (e.g. if a new row was created or a row was updated) and then it will be cleared, which has the effect of ending its scope even though its lexical scope may be longer.
this clearing of the buffer also has the effect of ending or reducing the "lock scope".
if the buffer contains a row with a lock and it is released inside a transaction, then the buffer will be cleared but the row lock will not be released /until the transaction ends/.
if the buffer contains a row with a share lock and it is released outside a transaction, then the row lock will be released when the buffer is cleared.
if the buffer contains a row with a NO-LOCK then there is no lock to release when the buffer is cleared and inside or outside a transaction makes no difference.
note that after you release a buffer, you can read something else into it (or even the same thing).