Skip to main content

Questions tagged [for-update]

Filter by
Sorted by
Tagged with
0 votes
1 answer
55 views

System.QueryException: Record Currently Unavailable

Im getting the following error: caused by: System.QueryException: Record Currently Unavailable: The record you are attempting to edit, or one of its related records, is currently being modified by ...
Thomas's user avatar
  • 2,320
3 votes
2 answers
710 views

Does Database.rollback on a savepoint release Select for Update locks

I'm trying to understand Salesforce's locking mechanism. I ran a test which does the following: Calls Database.setSavepoint(). Issues a Select for Update query. Calls Database.rollback(savepoint). ...
silverglass's user avatar
4 votes
2 answers
568 views

SOQL - concurrent reads of rows when FOR UPDATE clause is used

Below is our scenario: We have a requirement to tag unique number to self service applications which are created through customer community. We tried to use salesforce auto number but our client had ...
RedDevil's user avatar
  • 7,851
0 votes
1 answer
64 views

how to store two different record type data i one list?

i have to add records of different records types in one list and upsert the same list how can i add records of different record type and upsert it List<fit__c> listToUpsert = new List<...
garvi's user avatar
  • 63
2 votes
1 answer
170 views

What effect does FOR UPDATE have on pending inserts?

FOR UPDATE will lock a row to prevent other clients from accessing it, as is well documented. Does FOR UPDATE have an effect on pending inserts from concurrent clients as well? For example, assume ...
ipavlic's user avatar
  • 3,736
4 votes
0 answers
85 views

Is this a good Model for "Guaranteeing" Record Updates Don't Fail due to ROW_LOCK/Race Conditions?

Background: The zqu__Quote__c object in our org has two child objects from another managed package we use for eSignature and credit card capture. One of those two child objects collects the Credit ...
Morgan Marchese's user avatar
4 votes
1 answer
1k views

Avoid new record race conditions with FOR UPDATE [closed]

Under simple circumstances FOR UPDATE does only respect records that existed when the query was executed. But I need all available records matching my query when the transaction proceeds. Let me ...
itsmebasti's user avatar
  • 6,525
0 votes
2 answers
384 views

Race condition Soql with order by

I have a lead owner assignment logic with many conditions. When user presses a button "Get lead" a lead in the org is searched and ordered by the field rank (Soql order by rank__c), and when the lead ...
daveDev's user avatar
  • 145
10 votes
1 answer
1k views

FOR UPDATE returns old values

I use FOR UPDATE locking in a query but when the first execution completed, the second execution (started while records were locked) seems to use the old data set. I played around for a while and ...
itsmebasti's user avatar
  • 6,525
6 votes
2 answers
405 views

Pessimistic Lock Released after Callout

The documentation says: The lock gets released when the transaction completes. However I can validate that it also gets released when a callout is made! Here a two test methods: public static ...
r2ric's user avatar
  • 61
11 votes
1 answer
3k views

When is a FOR UPDATE lock released?

The Salesforce docs say that The lock gets released when the transaction completes Does that mean when the record is updated, or when the execution context completes?
Sean Kearon's user avatar
0 votes
1 answer
69 views

Can a web service callout be made in code that has a "for update" lock applied?

I believe a motivation for the platform not allowing DML before a web service callout is to avoid a long-lived transaction (as the callout is allowed to wait up to 10 seconds for its response). I ...
Keith C's user avatar
  • 137k
0 votes
1 answer
229 views

FOR UPDATE in a Subquery?

I am assigned a POC project to consciously attempt a record and its children from one block of code and the other block of code would try to see how an update on such locked records behave. I am fine ...
SF Learner's user avatar
  • 1,037
11 votes
1 answer
2k views

Transaction isolation in Salesforce

As far as I understand Salesforce supports optimistic (by default) and pessimistic (using FOR UPDATE) locking for records. But what about transactions? If there direct analogy for typical SQL ...
Mike Raven's user avatar
  • 2,133
51 votes
5 answers
20k views

SOQL Record Locking : For Update

Well I was trying to Implement Record Locking apex but Salesforce Document doesn't seem to help much. Even tried searching stackexchange there was a old question but the answer form StackExchange and ...
Avidev9's user avatar
  • 5,679
1 vote
1 answer
102 views

Mass field update

Some of my Accounts are known as Ultimate Parents. They are either parent or grandparent to all other Accounts for a particular company. Due to a large data migration, I would like to have the ...
Zoom_v's user avatar
  • 3,904
38 votes
1 answer
670 views

Help me solve a concurrency mystery (platform bug? Expected behavior? Or am I missing something?)

To set up the problem, add a new currency data type custom field called Test_Counter__c to the Opportunity Object. Then create a test opportunity named TestOp. Then create the following class: ...
kibitzer's user avatar
  • 3,444