Skip to content

Commit 934e2c9

Browse files
authored
v1.3.19 - Combating Record Lock Issues (#222)
* Combating record lock issues generated by overnight scheduled rollup runs - `FOR UPDATE` was too aggressively locking the parent records in these cases
1 parent 18d2a39 commit 934e2c9

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ You have several different options when it comes to making use of `Rollup`:
2222

2323
## Deployment
2424

25-
<a href="https://login.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008SiUyAAK">
25+
<a href="https://login.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008SiVIAA0">
2626
<img alt="Deploy to Salesforce"
2727
src="./media/deploy-package-to-prod.png">
2828
</a>
2929

30-
<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008SiUyAAK">
30+
<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008SiVIAA0">
3131
<img alt="Deploy to Salesforce Sandbox"
3232
src="./media/deploy-package-to-sandbox.png">
3333
</a>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "apex-rollup",
3-
"version": "1.3.18",
3+
"version": "1.3.19",
44
"description": "Fast, configurable, elastically scaling custom rollup solution. Apex Invocable action, one-liner Apex trigger/CMDT-driven logic, and scheduled Apex-ready.",
55
"repository": {
66
"type": "git",

rollup/core/classes/RollupAsyncProcessor.cls

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ global virtual without sharing class RollupAsyncProcessor extends Rollup impleme
411411
return System.enqueueJob(this);
412412
}
413413

414+
@SuppressWarnings('PMD.ApexSOQLInjection')
414415
protected override List<SObject> getExistingLookupItems(Set<String> objIds, RollupAsyncProcessor rollup, Set<String> uniqueQueryFieldNames) {
415416
if (objIds.isEmpty()) {
416417
return new List<SObject>();
@@ -433,7 +434,7 @@ global virtual without sharing class RollupAsyncProcessor extends Rollup impleme
433434
new List<String>(uniqueQueryFieldNames),
434435
String.valueOf(rollup.lookupFieldOnLookupObject),
435436
'='
436-
) + '\nFOR UPDATE';
437+
) + (this.isSingleRecordSyncUpdate(rollup) ? '\nFOR UPDATE' : '');
437438
// non-obvious coupling between "objIds" and the computed "queryString", which uses dynamic variable binding
438439
localLookupItems = Database.query(queryString);
439440
}
@@ -925,8 +926,7 @@ global virtual without sharing class RollupAsyncProcessor extends Rollup impleme
925926
rollup.rollupControl.ShouldRunAs__c == RollupMetaPicklists.ShouldRunAs.Synchronous ||
926927
((hasExceededCurrentRollupLimits(rollup.rollupControl) == false) && isRunningAsync) ||
927928
System.isBatch() && Limits.getQueueableJobs() >= Limits.getLimitQueueableJobs() ||
928-
this.calcItems?.size() == 1 &&
929-
(this.rollupControl.ShouldRunSingleRecordsSynchronously__c || rollup.rollupControl.ShouldRunSingleRecordsSynchronously__c);
929+
this.isSingleRecordSyncUpdate(rollup);
930930

931931
if (rollup.rollupControl.ShouldAbortRun__c || this.rollupControl.ShouldAbortRun__c) {
932932
this.rollups.remove(index);
@@ -943,6 +943,11 @@ global virtual without sharing class RollupAsyncProcessor extends Rollup impleme
943943
}
944944
}
945945

946+
private Boolean isSingleRecordSyncUpdate(RollupAsyncProcessor roll) {
947+
return this.calcItems?.size() == 1 &&
948+
(this.rollupControl.ShouldRunSingleRecordsSynchronously__c || roll.rollupControl.ShouldRunSingleRecordsSynchronously__c);
949+
}
950+
946951
private void overrideParentRollupControlValues(RollupControl__mdt specificControl) {
947952
// override section - most updates go from a rollup specific control -> this.rollupControl
948953
if (specificControl.BatchChunkSize__c < this.rollupControl.BatchChunkSize__c) {

sfdx-project.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"default": true,
55
"package": "apex-rollup",
66
"path": "rollup",
7-
"versionName": "Adding more formula tests, created Code Coverage plugin",
8-
"versionNumber": "1.3.18.0",
7+
"versionName": "Removing record locking from all but single record sync updates to combat issues from 1.3.18",
8+
"versionNumber": "1.3.19.0",
99
"versionDescription": "Fast, configurable, elastically scaling custom rollup solution. Apex Invocable action, one-liner Apex trigger/CMDT-driven logic, and scheduled Apex-ready.",
1010
"releaseNotesUrl": "https://github.com/jamessimone/apex-rollup/releases/latest",
1111
"unpackagedMetadata": {
@@ -107,6 +107,7 @@
107107
"[email protected]": "04t6g000008SiSdAAK",
108108
"Apex Rollup - Extra Code [email protected]": "04t6g000008SiTHAA0",
109109
"[email protected]": "04t6g000008SiTgAAK",
110-
"[email protected]": "04t6g000008SiUyAAK"
110+
"[email protected]": "04t6g000008SiUyAAK",
111+
"[email protected]": "04t6g000008SiVIAA0"
111112
}
112113
}

0 commit comments

Comments
 (0)