944
Views
2
Comments
Release lock when using GetForUpdate
Question

When I use GetForUpdate<Entity>, it locks my entity. My question is when it release the lock?

I search the answer for a day but can not get a deserved one

2020-03-17 03-08-19
Steve Bramley

once the entire transaction is complete, the whole action or screen action the getforupdate is called from.  You may be able to force a release by using the commit action though.  (System) > Server Actions > CommitTransaction

2019-11-01 16-10-49
Nélio Dionisio

Hi Pham :),


As stated in the documentation "the GetForUpdate"(https://www.outsystems.com/help/ServiceStudio/9.1/index.htm#t=Using_Data%2FGet_for_Update_Action.htm) action locks the record in the database until the transaction is finished, preventing other processes from accessing this record".

So, the 2nd transaction accessing the same row waits for the lock from the 1st transaction to be released - which happens implicitly when the transaction / request ends (web service, screen action, etc). 

You can use the built-in CommitTransaction action to end the transaction sooner, otherwise it's committed when the request ends.


I hope it helps.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.