Skip to main content
14 votes

SOQL Record Locking (FOR UPDATE)

I performed 4 experiments, take a look: Experiment 1 Description: User A SOQL for a record without FOR UPDATE statement and has long running transaction. User B SOQL for a record without FOR UPDATE ...
Nobi992's user avatar
  • 370
8 votes
Accepted

ConcurrentPerOrgLongTxn Limit exceeded. Does SOQL query and Apex Callout timings gets counted

As the Execution Governors and Limits documentation states: Description Limit Number of synchronous concurrent transactions for long-running transactions that last longer than 5 seconds for each org....
sfdcfox's user avatar
  • 495k
6 votes
Accepted

Optimistic locking when working via REST API

If the Ruby script updates a record between the time the user loads the edit page and clicks Save, they'll get a "record has been modified" error to prevent them from overwriting data. If the user ...
sfdcfox's user avatar
  • 495k
5 votes
Accepted

When using FOR UPDATE does Salesforce also lock the child records in a master-detail relationship?

No. You must independently lock child records that you're interested in. Also see Avoiding Deadlocks, where they mention: Apex has the possibility of deadlocks, as does any other procedural logic ...
sfdcfox's user avatar
  • 495k
4 votes

Concurrency issue on Batches

You should be using row-locking mechanisms in both jobs so that you can ensure that the A records do or do not exist before attempting to perform the main logic: // Job A public void execute(Database....
sfdcfox's user avatar
  • 495k
4 votes

Best practices for protecting your app/package from integrations with harmful side effects

As a customer who customizes and "breaks" some of our managed packages on a regular basis, I would say documentation, documentation, documentation! Find out what your customers are trying to do, and ...
Lisa's user avatar
  • 174
4 votes

future method concurrency

You can use a locking statement to help combat this problem. Basically, you just need to take whatever your original query was and add FOR UPDATE to the end of it; if any records are in flight but not ...
sfdcfox's user avatar
  • 495k
3 votes

Can I chain Bulk API jobs?

If you are writing your own script, you can certainly chain them however you wish to. Here is a simple Node.js script showing how to achieve this, const jsforce = require('jsforce'); const sfbulk = ...
Mohith Shrivastava's user avatar
3 votes

How to set the concurrencyMode using the new Bulk API 2.0

Setting the concurrencyMode in V2 is not possible. I recently had the same issue and Salesforce support recommend using the V1 API to prevent the "row locking" issues we were having with V2.
Allan Munro's user avatar
3 votes
Accepted

How does Salesforce ensure new record IDs for the same object are unique during simultaneous inserts?

In short, yes, ID values will always be unique within an org. An ID may exist in multiple orgs, which happens when you clone an existing org, but the ID will be unique within that org. What happens is ...
sfdcfox's user avatar
  • 495k
3 votes
Accepted

Salesforce transaction mutexes

Yes, two transactions can absolutely overlap. Let's say for instance that Object takes about two seconds to save. Until that transaction completes, the number of records in the database won't change. ...
Adrian Larson's user avatar
  • 150k
3 votes
Accepted

Is an AsyncApexJob record inserted immediately at the end of a transaction?

I just tested this, and it's available immediately in the same transaction, before the current transaction completes. Obviously, this Id won't be available to other transactions before "final commit," ...
sfdcfox's user avatar
  • 495k
2 votes

Best practices for protecting your app/package from integrations with harmful side effects

I don't think you'll ever be able to shield your managed package from all the creative interactions it will have with customer orgs. There isn't much you can do if they aren't correctly bulkifying ...
Daniel Ballinger's user avatar
2 votes

Best practices for protecting your app/package from integrations with harmful side effects

As a Salesforce implementer that also "Breaks" existing integrations, I do agree with what Lisa has already stated. You guys are running into, what I understand, as an unfortunate side effect of ...
Chris's user avatar
  • 1,675
2 votes
Accepted

Is there a limit to how many concurrent or total retrievals you can make with Platform Cache?

Platform Cache is a Redis store(key-value pairs) and there are no concurrent limits on it simply because salesforce allows the data to be overwritten! Worst case there will be cache miss so one should ...
Mohith Shrivastava's user avatar
2 votes

Synchronization object in Apex Class during concurrent calls

Rather than using a Custom Setting, create a new unique External Id Text field on Activities (which includes Task and Event) to store the Call Id. Your code cannot reasonably expect to maintain a ...
David Reed's user avatar
  • 93.2k
2 votes
Accepted

How can I tell what the 'Maximum number of batch apex jobs queued or active concurrently' limit is in our org?

Not elegant, but you could write a class that schedules a trivial job many times (e.g. 20 for your situation) and count the AsyncApexJob rows that have a Status of other than "Holding". The results ...
Keith C's user avatar
  • 136k
2 votes

When the triggers run in context of a composite standard Rest api, which governor limit it comes under?

Sorry for the long post. But an interesting finding with data points. I did some testing around this. Here are my findings. FIRST services/data/v52.0/composite { "allOrNone":true, "...
Nagendra Singh's user avatar
2 votes

ConcurrentPerOrgLongTxn Limit exceeded. Does SOQL query and Apex Callout timings gets counted

I was able to replicate this exception in my org using https://github.com/koenfaro90/SFDC-ConcurrentPerOrgLongTxn-Reproduction I modified the code to hit the custom rest services which we have created ...
Nagendra Singh's user avatar
2 votes
Accepted

Multiple users and concurrent transactions

IMHO use of a custom settings is a bad idea; these are intended (like custom metadata type records) to be quite static. Continually updating the value is detrimental to performance. SOQL includes FOR ...
Phil W's user avatar
  • 36.8k
1 vote

Property currently unsupported: 'concurrencyMode'

I was able to solve this finally. Looks like Salesforce was expecting the xml attributes to be passed in same order. Order change was causing the problem for me and was returning 400 Bad Request Error....
Manish Mehra's user avatar
1 vote

UNABLE_TO_LOCK_ROW issue in concurrent API call

SObject Tree creates one or more sObject trees with root records of the specified type. An sObject tree is a collection of nested, parent-child records with a single root record. In the request data, ...
Himanshu's user avatar
  • 10.5k
1 vote
Accepted

It is possible to set the concurrency mode for a Data Import Wizard job?

I don't think Import Wizard have the option to run bulk import in serial import as of now. The other workaround for this is use Data loader in data loader you have option to load data serially using ...
AtulRajguru9's user avatar
  • 9,120
1 vote
Accepted

Email handler bulk/concurrency issue

Following up on my last comment, it was indeed the UNABLE_TO_LOCK_ROW issue and adding FOR UPDATE to the relevant SOQL query seems to resolve the issue: [SELECT Name FROM Loan__Fee__c where Name=:'...
Philip Clark's user avatar
1 vote

How to Reproduce the Concurrent Requests Limit?

So I managed to create one of these in a package I built, so in case it's helpful here's what I did that caused the error. I had a synchronous callout to web service. In the response was some data ...
BritishBoyinDC's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible