function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Puneet KhoslaPuneet Khosla 

Query regarding Partial loads (through data loader or Database.insert with false paramater) with error record

When you do a load through data loader or using Database.insert (or update) using false as a parameter, then ideally it should allow successful records to save and error records to give an error. Though this is happening, however I observed that recently its taking 2 iterations to save and not one if there is a record in the batch with a missing required field data, thus resulting in triggers, workflows, validations , etc. to run twice.
 
What's worse is CPU usage is not reset in 2nd iteration though SOQL limits are getting reset. Thus resulting in almost double overall CPU and leading to CPU timeouts.
 
If we put a recursion control, then the data that gets saved without trigger processing for the 2nd time, causing data quality issues.
 
Is this a bug or it was there before or do we need to do something in the code to ensure that records are saved in first time?
 
To replicate this.
Create a new custom object (Call it Dummy Object)
Make 2-3 custom text fields (Name1, Name2, Name3) , out of which Name 2 is a required field
Write a trigger
Before Insert – Make Name3 = Name 2
After Insert – Print in Debug logs My name is <Name 3>
Load 3 records first through data loader(batch size 200 with no bulk API) and Anonymous (using Database.insert false) with the following condition
1st  record has Name 1 as ABC and Name 2 as DEF.
2nd record has no value in Name 1 and Name 2
3rd record has XYZ in Name 2
If you open Debug  logs, you will see 2 iterations. If you stop the iteration through recursion control, Name 3 is not populated in records.