You need to sign in to do that
Don't have an account?
could & rock
Call Insert API twice in case of batch data loading failure - who made the second call?
Here's the situation I ran into, and wondering if anyone can help clairify who makes the second record insert call, the Data loader tool or the SFDC platform itself.
- Create a simple custom object
- Add one validation rule
- Create a insert before/after trigger for debugging
- Use data loader load 2 records, one is OK, one will fail the validation rule
- Set data loader batch size as 200, and insert those 2 records
- Data loader shows one was success, one was failure.
- Check the debug log, and find insert action were fired twice. the full process of before insert trigger + after insert tirgger were executed twice.
- On the first insert call, 2 records were fed into trigger, on the second insert call, only one record was fed into trigger, with the error one excluded.
It seemed in the case of batch data loading failure, 2 insert are made, one with all data, one with only correct data. Question is who initiates the second call, the data loader tool or SFDC platform itself?
Here's the full log.
32.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
15:23:34.027 (27699658)|EXECUTION_STARTED
15:23:34.027 (27726456)|CODE_UNIT_STARTED|[EXTERNAL]|TRIGGERS
15:23:34.027 (27759041)|CODE_UNIT_STARTED|[EXTERNAL]|01q17000000CfIF|jamesLogTrigger on TmpTest trigger event BeforeInsert for [new, new]
15:23:34.028 (28502159)|SYSTEM_METHOD_ENTRY|[2]|System.debug(ANY)
15:23:34.028 (28531380)|USER_DEBUG|[2]|DEBUG|xxx:before insert
15:23:34.028 (28537564)|SYSTEM_METHOD_EXIT|[2]|System.debug(ANY)
15:23:34.028 (28648855)|SYSTEM_METHOD_ENTRY|[3]|System.debug(ANY)
15:23:34.029 (29091106)|USER_DEBUG|[3]|DEBUG|(TmpTest__c:{LastModifiedById=null, OwnerId=005o0000000MaIbAAK, LastModifiedDate=null, Name=test, SystemModstamp=null, CreatedById=null, CreatedDate=null, IsDeleted=false, Id=null}, TmpTest__c:{LastModifiedById=null, OwnerId=005o0000000MaIbAAK, LastModifiedDate=null, Name=test1, SystemModstamp=null, CreatedById=null, CreatedDate=null, IsDeleted=false, Id=null})
15:23:34.029 (29105870)|SYSTEM_METHOD_EXIT|[3]|System.debug(ANY)
15:23:34.943 (29139047)|CUMULATIVE_LIMIT_USAGE
15:23:34.943|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
15:23:34.943|CUMULATIVE_LIMIT_USAGE_END
15:23:34.029 (29232042)|CODE_UNIT_FINISHED|jamesLogTrigger on TmpTest trigger event BeforeInsert for [new, new]
15:23:34.032 (32413349)|CODE_UNIT_STARTED|[EXTERNAL]|Validation:TmpTest:new
15:23:34.032 (32423468)|VALIDATION_RULE|03d170000008VN9|Name_contains_test
15:23:34.032 (32530584)|VALIDATION_FORMULA|Name = 'test'|Name=test
15:23:34.032 (32544649)|VALIDATION_FAIL
15:23:34.032 (32902915)|CODE_UNIT_FINISHED|Validation:TmpTest:new
15:23:34.032 (32916596)|CODE_UNIT_STARTED|[EXTERNAL]|Validation:TmpTest:new
15:23:34.032 (32922574)|VALIDATION_RULE|03d170000008VN9|Name_contains_test
15:23:34.033 (33020917)|VALIDATION_FORMULA|Name = 'test'|Name=test1
15:23:34.033 (33029305)|VALIDATION_PASS
15:23:34.033 (33046826)|CODE_UNIT_FINISHED|Validation:TmpTest:new
15:23:34.151 (151794896)|CODE_UNIT_STARTED|[EXTERNAL]|01q17000000CfIF|jamesLogTrigger on TmpTest trigger event AfterInsert for [a0Y1700000059nC]
15:23:34.151 (151941678)|SYSTEM_METHOD_ENTRY|[2]|System.debug(ANY)
15:23:34.151 (151954107)|USER_DEBUG|[2]|DEBUG|xxx:after insert
15:23:34.151 (151962871)|SYSTEM_METHOD_EXIT|[2]|System.debug(ANY)
15:23:34.151 (151985313)|SYSTEM_METHOD_ENTRY|[3]|System.debug(ANY)
15:23:34.152 (152212383)|USER_DEBUG|[3]|DEBUG|(TmpTest__c:{LastModifiedById=005o0000000MaIbAAK, OwnerId=005o0000000MaIbAAK, LastModifiedDate=2014-12-19 20:23:34, Name=test1, SystemModstamp=2014-12-19 20:23:34, CreatedById=005o0000000MaIbAAK, CreatedDate=2014-12-19 20:23:34, IsDeleted=false, Id=a0Y1700000059nCEAQ})
15:23:34.152 (152226836)|SYSTEM_METHOD_EXIT|[3]|System.debug(ANY)
15:23:35.066 (152257960)|CUMULATIVE_LIMIT_USAGE
15:23:35.066|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
15:23:35.066|CUMULATIVE_LIMIT_USAGE_END
15:23:34.152 (152343360)|CODE_UNIT_FINISHED|jamesLogTrigger on TmpTest trigger event AfterInsert for [a0Y1700000059nC]
15:23:34.154 (154479930)|CODE_UNIT_STARTED|[EXTERNAL]|01q17000000CfIF|jamesLogTrigger on TmpTest trigger event BeforeInsert for [new]
15:23:34.154 (154582587)|SYSTEM_METHOD_ENTRY|[2]|System.debug(ANY)
15:23:34.154 (154593102)|USER_DEBUG|[2]|DEBUG|xxx:before insert
15:23:34.154 (154601720)|SYSTEM_METHOD_EXIT|[2]|System.debug(ANY)
15:23:34.154 (154621062)|SYSTEM_METHOD_ENTRY|[3]|System.debug(ANY)
15:23:34.154 (154802991)|USER_DEBUG|[3]|DEBUG|(TmpTest__c:{LastModifiedById=null, OwnerId=005o0000000MaIbAAK, LastModifiedDate=null, Name=test1, SystemModstamp=null, CreatedById=null, CreatedDate=null, IsDeleted=false, Id=null})
15:23:34.154 (154815122)|SYSTEM_METHOD_EXIT|[3]|System.debug(ANY)
15:23:35.069 (154834819)|CUMULATIVE_LIMIT_USAGE
15:23:35.069|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
15:23:35.069|CUMULATIVE_LIMIT_USAGE_END
15:23:34.154 (154902138)|CODE_UNIT_FINISHED|jamesLogTrigger on TmpTest trigger event BeforeInsert for [new]
15:23:34.155 (155206707)|CODE_UNIT_STARTED|[EXTERNAL]|Validation:TmpTest:new
15:23:34.155 (155217483)|VALIDATION_RULE|03d170000008VN9|Name_contains_test
15:23:34.155 (155309312)|VALIDATION_FORMULA|Name = 'test'|Name=test1
15:23:34.155 (155317194)|VALIDATION_PASS
15:23:34.155 (155334396)|CODE_UNIT_FINISHED|Validation:TmpTest:new
15:23:34.179 (179128975)|CODE_UNIT_STARTED|[EXTERNAL]|01q17000000CfIF|jamesLogTrigger on TmpTest trigger event AfterInsert for [a0Y1700000059nD]
15:23:34.179 (179228557)|SYSTEM_METHOD_ENTRY|[2]|System.debug(ANY)
15:23:34.179 (179236749)|USER_DEBUG|[2]|DEBUG|xxx:after insert
15:23:34.179 (179241424)|SYSTEM_METHOD_EXIT|[2]|System.debug(ANY)
15:23:34.179 (179253653)|SYSTEM_METHOD_ENTRY|[3]|System.debug(ANY)
15:23:34.179 (179355750)|USER_DEBUG|[3]|DEBUG|(TmpTest__c:{LastModifiedById=005o0000000MaIbAAK, OwnerId=005o0000000MaIbAAK, LastModifiedDate=2014-12-19 20:23:35, Name=test1, SystemModstamp=2014-12-19 20:23:35, CreatedById=005o0000000MaIbAAK, CreatedDate=2014-12-19 20:23:35, IsDeleted=false, Id=a0Y1700000059nDEAQ})
15:23:34.179 (179363699)|SYSTEM_METHOD_EXIT|[3]|System.debug(ANY)
15:23:35.093 (179380116)|CUMULATIVE_LIMIT_USAGE
15:23:35.093|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
15:23:35.093|CUMULATIVE_LIMIT_USAGE_END
15:23:34.179 (179434704)|CODE_UNIT_FINISHED|jamesLogTrigger on TmpTest trigger event AfterInsert for [a0Y1700000059nD]
15:23:34.190 (190568844)|CODE_UNIT_FINISHED|TRIGGERS
15:23:34.190 (190582363)|EXECUTION_FINISHED
- Create a simple custom object
- Add one validation rule
- Create a insert before/after trigger for debugging
- Use data loader load 2 records, one is OK, one will fail the validation rule
- Set data loader batch size as 200, and insert those 2 records
- Data loader shows one was success, one was failure.
- Check the debug log, and find insert action were fired twice. the full process of before insert trigger + after insert tirgger were executed twice.
- On the first insert call, 2 records were fed into trigger, on the second insert call, only one record was fed into trigger, with the error one excluded.
It seemed in the case of batch data loading failure, 2 insert are made, one with all data, one with only correct data. Question is who initiates the second call, the data loader tool or SFDC platform itself?
Here's the full log.
32.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
15:23:34.027 (27699658)|EXECUTION_STARTED
15:23:34.027 (27726456)|CODE_UNIT_STARTED|[EXTERNAL]|TRIGGERS
15:23:34.027 (27759041)|CODE_UNIT_STARTED|[EXTERNAL]|01q17000000CfIF|jamesLogTrigger on TmpTest trigger event BeforeInsert for [new, new]
15:23:34.028 (28502159)|SYSTEM_METHOD_ENTRY|[2]|System.debug(ANY)
15:23:34.028 (28531380)|USER_DEBUG|[2]|DEBUG|xxx:before insert
15:23:34.028 (28537564)|SYSTEM_METHOD_EXIT|[2]|System.debug(ANY)
15:23:34.028 (28648855)|SYSTEM_METHOD_ENTRY|[3]|System.debug(ANY)
15:23:34.029 (29091106)|USER_DEBUG|[3]|DEBUG|(TmpTest__c:{LastModifiedById=null, OwnerId=005o0000000MaIbAAK, LastModifiedDate=null, Name=test, SystemModstamp=null, CreatedById=null, CreatedDate=null, IsDeleted=false, Id=null}, TmpTest__c:{LastModifiedById=null, OwnerId=005o0000000MaIbAAK, LastModifiedDate=null, Name=test1, SystemModstamp=null, CreatedById=null, CreatedDate=null, IsDeleted=false, Id=null})
15:23:34.029 (29105870)|SYSTEM_METHOD_EXIT|[3]|System.debug(ANY)
15:23:34.943 (29139047)|CUMULATIVE_LIMIT_USAGE
15:23:34.943|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
15:23:34.943|CUMULATIVE_LIMIT_USAGE_END
15:23:34.029 (29232042)|CODE_UNIT_FINISHED|jamesLogTrigger on TmpTest trigger event BeforeInsert for [new, new]
15:23:34.032 (32413349)|CODE_UNIT_STARTED|[EXTERNAL]|Validation:TmpTest:new
15:23:34.032 (32423468)|VALIDATION_RULE|03d170000008VN9|Name_contains_test
15:23:34.032 (32530584)|VALIDATION_FORMULA|Name = 'test'|Name=test
15:23:34.032 (32544649)|VALIDATION_FAIL
15:23:34.032 (32902915)|CODE_UNIT_FINISHED|Validation:TmpTest:new
15:23:34.032 (32916596)|CODE_UNIT_STARTED|[EXTERNAL]|Validation:TmpTest:new
15:23:34.032 (32922574)|VALIDATION_RULE|03d170000008VN9|Name_contains_test
15:23:34.033 (33020917)|VALIDATION_FORMULA|Name = 'test'|Name=test1
15:23:34.033 (33029305)|VALIDATION_PASS
15:23:34.033 (33046826)|CODE_UNIT_FINISHED|Validation:TmpTest:new
15:23:34.151 (151794896)|CODE_UNIT_STARTED|[EXTERNAL]|01q17000000CfIF|jamesLogTrigger on TmpTest trigger event AfterInsert for [a0Y1700000059nC]
15:23:34.151 (151941678)|SYSTEM_METHOD_ENTRY|[2]|System.debug(ANY)
15:23:34.151 (151954107)|USER_DEBUG|[2]|DEBUG|xxx:after insert
15:23:34.151 (151962871)|SYSTEM_METHOD_EXIT|[2]|System.debug(ANY)
15:23:34.151 (151985313)|SYSTEM_METHOD_ENTRY|[3]|System.debug(ANY)
15:23:34.152 (152212383)|USER_DEBUG|[3]|DEBUG|(TmpTest__c:{LastModifiedById=005o0000000MaIbAAK, OwnerId=005o0000000MaIbAAK, LastModifiedDate=2014-12-19 20:23:34, Name=test1, SystemModstamp=2014-12-19 20:23:34, CreatedById=005o0000000MaIbAAK, CreatedDate=2014-12-19 20:23:34, IsDeleted=false, Id=a0Y1700000059nCEAQ})
15:23:34.152 (152226836)|SYSTEM_METHOD_EXIT|[3]|System.debug(ANY)
15:23:35.066 (152257960)|CUMULATIVE_LIMIT_USAGE
15:23:35.066|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
15:23:35.066|CUMULATIVE_LIMIT_USAGE_END
15:23:34.152 (152343360)|CODE_UNIT_FINISHED|jamesLogTrigger on TmpTest trigger event AfterInsert for [a0Y1700000059nC]
15:23:34.154 (154479930)|CODE_UNIT_STARTED|[EXTERNAL]|01q17000000CfIF|jamesLogTrigger on TmpTest trigger event BeforeInsert for [new]
15:23:34.154 (154582587)|SYSTEM_METHOD_ENTRY|[2]|System.debug(ANY)
15:23:34.154 (154593102)|USER_DEBUG|[2]|DEBUG|xxx:before insert
15:23:34.154 (154601720)|SYSTEM_METHOD_EXIT|[2]|System.debug(ANY)
15:23:34.154 (154621062)|SYSTEM_METHOD_ENTRY|[3]|System.debug(ANY)
15:23:34.154 (154802991)|USER_DEBUG|[3]|DEBUG|(TmpTest__c:{LastModifiedById=null, OwnerId=005o0000000MaIbAAK, LastModifiedDate=null, Name=test1, SystemModstamp=null, CreatedById=null, CreatedDate=null, IsDeleted=false, Id=null})
15:23:34.154 (154815122)|SYSTEM_METHOD_EXIT|[3]|System.debug(ANY)
15:23:35.069 (154834819)|CUMULATIVE_LIMIT_USAGE
15:23:35.069|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
15:23:35.069|CUMULATIVE_LIMIT_USAGE_END
15:23:34.154 (154902138)|CODE_UNIT_FINISHED|jamesLogTrigger on TmpTest trigger event BeforeInsert for [new]
15:23:34.155 (155206707)|CODE_UNIT_STARTED|[EXTERNAL]|Validation:TmpTest:new
15:23:34.155 (155217483)|VALIDATION_RULE|03d170000008VN9|Name_contains_test
15:23:34.155 (155309312)|VALIDATION_FORMULA|Name = 'test'|Name=test1
15:23:34.155 (155317194)|VALIDATION_PASS
15:23:34.155 (155334396)|CODE_UNIT_FINISHED|Validation:TmpTest:new
15:23:34.179 (179128975)|CODE_UNIT_STARTED|[EXTERNAL]|01q17000000CfIF|jamesLogTrigger on TmpTest trigger event AfterInsert for [a0Y1700000059nD]
15:23:34.179 (179228557)|SYSTEM_METHOD_ENTRY|[2]|System.debug(ANY)
15:23:34.179 (179236749)|USER_DEBUG|[2]|DEBUG|xxx:after insert
15:23:34.179 (179241424)|SYSTEM_METHOD_EXIT|[2]|System.debug(ANY)
15:23:34.179 (179253653)|SYSTEM_METHOD_ENTRY|[3]|System.debug(ANY)
15:23:34.179 (179355750)|USER_DEBUG|[3]|DEBUG|(TmpTest__c:{LastModifiedById=005o0000000MaIbAAK, OwnerId=005o0000000MaIbAAK, LastModifiedDate=2014-12-19 20:23:35, Name=test1, SystemModstamp=2014-12-19 20:23:35, CreatedById=005o0000000MaIbAAK, CreatedDate=2014-12-19 20:23:35, IsDeleted=false, Id=a0Y1700000059nDEAQ})
15:23:34.179 (179363699)|SYSTEM_METHOD_EXIT|[3]|System.debug(ANY)
15:23:35.093 (179380116)|CUMULATIVE_LIMIT_USAGE
15:23:35.093|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 100
Number of Email Invocations: 0 out of 10
Number of future calls: 0 out of 50
Number of queueable jobs added to the queue: 0 out of 50
Number of Mobile Apex push calls: 0 out of 10
15:23:35.093|CUMULATIVE_LIMIT_USAGE_END
15:23:34.179 (179434704)|CODE_UNIT_FINISHED|jamesLogTrigger on TmpTest trigger event AfterInsert for [a0Y1700000059nD]
15:23:34.190 (190568844)|CODE_UNIT_FINISHED|TRIGGERS
15:23:34.190 (190582363)|EXECUTION_FINISHED
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dml_bulk_exceptions.htm
In a partial saving case, at least 2 attempts are made. Are the records without error in the first attempt committed to database or not?
Or all records included in the first-time attempt are rolled back, and never saved into database?