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
shrayas reddyshrayas reddy 

I am getting an error That is FATAL_ERROR Internal Salesforce.com Error when i run a batch class

global class PriceListUpdate implements Database.Batchable<sObject>{
   global Database.QueryLocator start(Database.BatchableContext BC)
    {
        String query = 'select id,Name,Global_Product_Manager_SIG__c from product2';
        return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext BC, List<product2> scopeList){
        List<Price_Record_SIG__c> priceList = new List<Price_Record_SIG__c>();
        Map<Id,Id> listData = new Map<Id,Id>();
        for(product2 p:scopeList){
            listData.put(p.Id,p.Global_Product_Manager_SIG__c);
        }
        List<Price_Record_SIG__c> priceRcd = [Select Id,name,Product_Name_Code_SIG__r.Global_Product_Manager_SIG__c,Product_Name_Code_SIG__c,Product_Manager_SIG__c from Price_Record_SIG__c where Product_Name_Code_SIG__c =: listData.keySet()];
        if(priceRcd.size()>0){
            for(Id ids : listData.keySet()){
            for(Price_Record_SIG__c price:priceRcd){               
                    if(ids == price.Product_Name_Code_SIG__c){
                       // System.debug('Equal==>'+ids == price.Product_Name_Code_SIG__c);
                        System.debug('listData.get(ids)==>'+listData.get(ids));
                        price.Product_Manager_SIG__c = listData.get(ids);
                        System.debug('price.Product_Manager_SIG__c==>'+price.Product_Manager_SIG__c);
                        priceList.add(price);
                    }
                }
            }
        }
        if(priceList.size()>0){
            update priceList;
        }
        
    } 
    global void finish (Database.BatchableContext BC){
        System.debug('Batch job Completed successfully');
    }
    
}



/* In ananymous window I am running below code*/

PriceListUpdate up = new PriceListUpdate();
database.executeBatch(up,200);
SubratSubrat (Salesforce Developers) 
Hello Shreyas ,

Can you Try running the batch class with a smaller batch size to see if that resolves the issue. The current batch size in your code is 200, you can try reducing it to 50 or 100.

Hope it helps !
Thank you.
shrayas reddyshrayas reddy
Hi Subrat,
               I tried it will be sucessful for some batches then a particular batch fails and i get the above error