You need to sign in to do that
Don't have an account?
EJW
Summer '14 bug - Limits.getScriptStatements() always reporting you've executed 200,000 script statements.
I've opened a case for this, 10197829, but wanted to report it here as well in hopes of getting it noticed/resolved faster. I realize this limit is no longer enforced, but older code that checks to see if the limit has been exceeded is now erroring out due to this issue. Yes, the code can be fixed but in this case the code is part of a managed package with several major versions in the wild and fixing this would require fixing and pushing updates to almost 30 different major releases.
To reproduce the issue, simply execute this in the developer console:
System.debug( Limits.getScriptStatements() );
You'll see that it both returns 200,000 and the cumulative stats will report that 200,000 of 200,000 script statements have been executed. See this log:
30.0 APEX_CODE,DEBUG;APEX_PROFILING,FINEST;CALLOUT,ERROR;DB,DEBUG;SYSTEM,DEBUG;VALIDATION,ERROR;VISUALFORCE,ERROR;WORKFLOW,ERROR
Execute Anonymous: System.debug( Limits.getScriptStatements() );
Execute Anonymous: System.debug( Limits.getLimitScriptStatements() );
09:04:43.038 (38268000)|EXECUTION_STARTED
09:04:43.038 (38284000)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
09:04:43.038 (38842000)|SYSTEM_METHOD_ENTRY|[1]|Limit.getScriptStatements()
09:04:43.038 (38906000)|SYSTEM_METHOD_EXIT|[1]|Limit.getScriptStatements()
09:04:43.038 (38930000)|SYSTEM_METHOD_ENTRY|[1]|System.debug(ANY)
09:04:43.038 (38945000)|USER_DEBUG|[1]|DEBUG|200000
09:04:43.038 (38953000)|SYSTEM_METHOD_EXIT|[1]|System.debug(ANY)
09:04:43.038 (38964000)|SYSTEM_METHOD_ENTRY|[2]|Limit.getLimitScriptStatements()
09:04:43.038 (38996000)|SYSTEM_METHOD_EXIT|[2]|Limit.getLimitScriptStatements()
09:04:43.039 (39008000)|SYSTEM_METHOD_ENTRY|[2]|System.debug(ANY)
09:04:43.039 (39019000)|USER_DEBUG|[2]|DEBUG|200000
09:04:43.039 (39027000)|SYSTEM_METHOD_EXIT|[2]|System.debug(ANY)
09:04:43.129 (39069000)|CUMULATIVE_LIMIT_USAGE
09:04:43.129|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
Number of code statements: 200000 out of 200000 ******* CLOSE TO LIMIT
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 10
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 10
To reproduce the issue, simply execute this in the developer console:
System.debug( Limits.getScriptStatements() );
You'll see that it both returns 200,000 and the cumulative stats will report that 200,000 of 200,000 script statements have been executed. See this log:
30.0 APEX_CODE,DEBUG;APEX_PROFILING,FINEST;CALLOUT,ERROR;DB,DEBUG;SYSTEM,DEBUG;VALIDATION,ERROR;VISUALFORCE,ERROR;WORKFLOW,ERROR
Execute Anonymous: System.debug( Limits.getScriptStatements() );
Execute Anonymous: System.debug( Limits.getLimitScriptStatements() );
09:04:43.038 (38268000)|EXECUTION_STARTED
09:04:43.038 (38284000)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
09:04:43.038 (38842000)|SYSTEM_METHOD_ENTRY|[1]|Limit.getScriptStatements()
09:04:43.038 (38906000)|SYSTEM_METHOD_EXIT|[1]|Limit.getScriptStatements()
09:04:43.038 (38930000)|SYSTEM_METHOD_ENTRY|[1]|System.debug(ANY)
09:04:43.038 (38945000)|USER_DEBUG|[1]|DEBUG|200000
09:04:43.038 (38953000)|SYSTEM_METHOD_EXIT|[1]|System.debug(ANY)
09:04:43.038 (38964000)|SYSTEM_METHOD_ENTRY|[2]|Limit.getLimitScriptStatements()
09:04:43.038 (38996000)|SYSTEM_METHOD_EXIT|[2]|Limit.getLimitScriptStatements()
09:04:43.039 (39008000)|SYSTEM_METHOD_ENTRY|[2]|System.debug(ANY)
09:04:43.039 (39019000)|USER_DEBUG|[2]|DEBUG|200000
09:04:43.039 (39027000)|SYSTEM_METHOD_EXIT|[2]|System.debug(ANY)
09:04:43.129 (39069000)|CUMULATIVE_LIMIT_USAGE
09:04:43.129|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
Number of code statements: 200000 out of 200000 ******* CLOSE TO LIMIT
Maximum CPU time: 0 out of 10000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 10
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 10
All Answers
Docs: http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_System_Limits_getScriptStatements.htm?SearchType=Stem
This change is for all API versions because script statements are no longer counted on the platform for all versions.
The fact that the solution they came up with is excellent does not negate the fact that somebody really screwed up on this one. I hope they are reviewing their internal processes to prevent this from happening again.