This issue we face generally when we have long running jobs.
Which one considers as long running job ?
In this context ,Any Synchronous Apex runs > 5 seconds considers as long running job.
When we get this error ?
Ex: If in your org governor limit allowed to run 10 concurrent jobs execute at a time and you get 11th job then you see this issue.
Solution ?
Try to move it to asynchronous wherever possible
How to identify which job / Apex causing this issue ?
It will be challenging to identify if you have larger code base /complex business functionality, So raise request to Salesforce to provide the root cause.
In our case we have signed for signature support and Part of proactive monitoring the details of which apex causing issue is shared.
If you don't fix this concurrent apex issue ,What happens ?
It will lead to performance issues & Fails to process the request which suppose to process can lead to business impact.
What is the apex causing issue in our case?
Inefficient SOQL Query : One of the SOQL query is taking
Avg Run Time : 9 Seconds
Max Run Time : 18 seconds
Note : This query is been used in frequent polling of our logic ,So definitely required to fix.
What is the solution for " Inefficient SOQL Query " ?
- Verify the query fields & Filter conditions - Query only required fields & Filter should be on indexed fields
- Verify the volume of table data - Always have the delete /purge jobs for older data and keep the table light
- Enabling the indexing can be done with external id enablement for quick thing
The volume numbers in our case ,Causing long running ?
Around 11 Lakhs records & 3 fields on the filter condition only 1 field is indexed.
Solution :
- Re-Arrange the query to have indexed fields take precedence in the filter condition.
- The other filter field is of data type "text area" so that cant be marked as external id to get the benefit of indexing, So 1st convert the data type "text area" to "text" by seeing the impact none of the existing records are >80 char length and future also not expected the same. Then mark that as external id .
- Another field is "Boolean" ,So this is not supported type of "External Id" & Need to re-thing enabling the index of this field really going to improve performance.
- Ex: if the records are 50% yes and 50% no, It doesn't make sense to index this field ?
- In our case it's not required to index Boolean field