Loading

SQLException 'User requested cancel of current operation'

Publish Date: Oct 13, 2022
Description

SQL Exception error can be encountered when running the "ABC" batch job "First error: SQLException [java.sql.SQLException: ORA-01013: user requested cancel of current operation] thrown but connection was canceled". The job is then aborted. 
Resolution

"ORA-01013: user requested cancel of current operation" is an error which come up for a number of reasons. One of the reasons being batch apex. However, you may also see it due to issues with Indexes.

A user friendly error message should be displayed instead, clarifying that the query was aborted since it took longer than 2 minutes to complete.

For a query to take longer to run you don't need to make any code changes. In fact the same query may work in different orgs, as the important factor is the distribution data. In other words, the same query may run fine in a sandbox where the total number of records (including soft-deleted ones) is X, but may time out in production where the total number of records is Y, where Y is greater than X.

The reason for this is that if a query is selective it will run faster as it will be index driven, if a query is unselective it will not be index driven and a full table scan will be necessary, which requires time proportional to the amount of records.

A query is selective when at least one filter returns less than 10% of the records up to 333k AND it is based on an indexed fields. There are standard indexed fields (like lookups, master detail relationships, unique, external id, and audit fields) and custom indexed fields (indexed by Salesforce).

You can use the Query plan tool to determine the selectivity of SOQL Query.
Knowledge Article Number

000385898

 
Loading
Salesforce Help | Article