+ Start a Discussion
nkwannkwan 

execute() method is not getting called with batch apex.

1. We are executing batch as follows:-
ID batchprocessid1 = Database.executeBatch(new batchAccountsImport(),8);

2. In batchAccountImport code snippet is as follows:-

global class batchAccountsImport implements Database.Batchable<SObject>,Database.AllowsCallouts { 

  public string soql = 'select id,safariUserId__c, isActive from User where isactive = true and safariUserid__c<>NULL LIMIT 2';
  global Database.queryLocator
                    start(Database.BatchableContext ctx){

        return Database.getQueryLocator(soql);
  }
  global void execute(Database.BatchableContext ctx, List<Sobject> scope){

// code

  }

  global void finish(Database.BatchableContext ctx) {

// code

  }

}


The execute method is not getting called and we are getting the CUMULATIVE_LIMIT_USAGE issue even when the query has been limited to 2 users.

Thanks

TanejaTaneja

Hello nkwan,

 

Do this:

 

batchAccountImport BC = new batchAccountImport();
Database.executeBatch(BC,8);

 

Best,

Ankit

 

Mark it as a Solution if it helped you. 

 

Wizno @ ConfigeroWizno @ Configero

How are you debugging this? CUMULATIVE_LIMIT_USAGE just lets you know a summary. 

Wizno @ ConfigeroWizno @ Configero
@Taneja your solution does exactly the same thing but separates the code into 2 lines.
nkwannkwan

@Taneja - I have tried the solution, but the issue is not resolved.

I have included the debug statement in the execute code, to check if the code is getting executed. And the debug statement is not getting printed.

Wizno @ ConfigeroWizno @ Configero

Can you post all the related logs?

 

The Operation name in the Developer Console for the actual execute statement will be 'SerialBatchApexrangeChunkHandler'

 

BTW, is this what the debug log looks like?

 

26.0 APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
16:49:47.024 (24498000)|EXECUTION_STARTED
16:49:47.024 (24543000)|CODE_UNIT_STARTED|[EXTERNAL]|01pE00000029VIl|Wizno.batchAccountsImport
16:49:47.026 (26992000)|HEAP_ALLOCATE|[56]|Bytes:3
16:49:47.027 (27066000)|HEAP_ALLOCATE|[61]|Bytes:152
16:49:47.027 (27098000)|HEAP_ALLOCATE|[249]|Bytes:408
16:49:47.027 (27127000)|HEAP_ALLOCATE|[262]|Bytes:408
16:49:47.027 (27155000)|HEAP_ALLOCATE|[356]|Bytes:48
16:49:47.027 (27233000)|HEAP_ALLOCATE|[114]|Bytes:6
16:49:47.028 (28495000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:67
16:49:47.041 (41782000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:6
16:49:47.041 (41795000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:272
16:49:47.041 (41810000)|METHOD_ENTRY|[1]|01pE00000029VIl|batchAccountsImport.batchAccountsImport()
16:49:47.041 (41816000)|STATEMENT_EXECUTE|[1]
16:49:47.041 (41822000)|STATEMENT_EXECUTE|[1]
16:49:47.041 (41826000)|METHOD_EXIT|[1]|batchAccountsImport
16:49:47.041 (41931000)|STATEMENT_EXECUTE|[4]
16:49:47.041 (41937000)|STATEMENT_EXECUTE|[5]
16:49:47.042 (42130000)|SYSTEM_METHOD_ENTRY|[5]|Database.getQueryLocator(String)
16:49:47.042 (42140000)|ENTERING_MANAGED_PKG|
16:49:47.043 (43834000)|SOQL_EXECUTE_BEGIN|[5]|Aggregations:0|select id, isActive from User 
16:49:47.074 (74066000)|SOQL_EXECUTE_END|[5]|Rows:1
16:49:47.074 (74129000)|HEAP_ALLOCATE|[5]|Bytes:20
16:49:47.074 (74147000)|SYSTEM_METHOD_EXIT|[5]|Database.getQueryLocator(String)
16:49:47.128 (102324000)|CUMULATIVE_LIMIT_USAGE
16:49:47.128|LIMIT_USAGE_FOR_NS|Wizno|
  Number of SOQL queries: 0 out of 200
  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
  Number of code statements: 1 out of 1000000
  Maximum heap size: 0 out of 12000000
  Number of callouts: 0 out of 0
  Number of Email Invocations: 0 out of 10
  Number of fields describes: 0 out of 100
  Number of record type describes: 0 out of 100
  Number of child relationships describes: 0 out of 100
  Number of picklist describes: 0 out of 100
  Number of future calls: 0 out of 0

16:49:47.128|CUMULATIVE_LIMIT_USAGE_END

16:49:47.102 (102360000)|CODE_UNIT_FINISHED|Wizno.batchAccountsImport
16:49:47.102 (102373000)|EXECUTION_FINISHED

 

nkwannkwan

The logs are mentionded below:-

 

25.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
14:09:32.045 (45299000)|EXECUTION_STARTED
14:09:32.045 (45346000)|CODE_UNIT_STARTED|[EXTERNAL]|01pd00000028wK2|batchAccountsImport
14:09:32.064 (64340000)|METHOD_ENTRY|[1]|01pd00000028wK2|batchAccountsImport.batchAccountsImport()
14:09:32.064 (64373000)|METHOD_EXIT|[1]|batchAccountsImport
14:09:32.064 (64708000)|SYSTEM_METHOD_ENTRY|[12]|System.debug(ANY)
14:09:32.064 (64749000)|USER_DEBUG|[12]|DEBUG|soql = select id,safariUserId__c, isActive from User where isactive = true and safariUserid__c<>NULL LIMIT 2
14:09:32.064 (64760000)|SYSTEM_METHOD_EXIT|[12]|System.debug(ANY)
14:09:32.064 (64785000)|SYSTEM_METHOD_ENTRY|[13]|Database.getQueryLocator(String)
14:09:32.066 (66939000)|SOQL_EXECUTE_BEGIN|[13]|Aggregations:0|select id,safariUserId__c, isActive from User 
14:09:32.112 (112883000)|SOQL_EXECUTE_END|[13]|Rows:2
14:09:32.112 (112968000)|SYSTEM_METHOD_EXIT|[13]|Database.getQueryLocator(String)
14:09:32.440 (161613000)|CUMULATIVE_LIMIT_USAGE
14:09:32.440|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 0 out of 200
  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
  Number of code statements: 2 out of 1000000
  Maximum heap size: 0 out of 12000000
  Number of callouts: 0 out of 0
  Number of Email Invocations: 0 out of 10
  Number of fields describes: 0 out of 100
  Number of record type describes: 0 out of 100
  Number of child relationships describes: 0 out of 100
  Number of picklist describes: 0 out of 100
  Number of future calls: 0 out of 0

14:09:32.440|CUMULATIVE_LIMIT_USAGE_END

14:09:32.161 (161656000)|CODE_UNIT_FINISHED|batchAccountsImport
14:09:32.161 (161672000)|EXECUTION_FINISHED
Wizno @ ConfigeroWizno @ Configero

You're looking at the wrong log. 

 

Look here: http://i40.tinypic.com/2r6p0ed.png

 

The highlighted part is where you need to be looking. The Execute part is going to be in one of those SerialBatchApexRangeChunkHandler operations.