Maximum execution time exceeded error while making an inbound REST call


Description

While making a rest call from an external third party to ServiceNow, it throws an error as 'Transaction cancelled: maximum execution time exceeded' below:


Error Log:

2020-11-18 18:13:04 (183) API_INT-thread-2 F78993F9DBE8A0105E65C3AF299619CB txid=3f8993f9dbe8 WARNING *** WARNING *** Transaction cancelled: maximum execution time exceeded
2020-11-18 18:13:04 (184) API_INT-thread-2 F78993F9DBE8A0105E65C3AF299619CB txid=3f8993f9dbe8 WARNING *** WARNING *** (conn=3406295) (conn=3406295) Query execution was interrupted
2020-11-18 18:13:04 (189) API_INT-thread-2 F78993F9DBE8A0105E65C3AF299619CB txid=3f8993f9dbe8 WARNING *** WARNING ***
2020-11-18 18:13:04 (199) API_INT-thread-2 F78993F9DBE8A0105E65C3AF299619CB txid=3f8993f9dbe8 SEVERE *** ERROR *** com.glide.sys.TransactionCancelledException: Transaction cancelled: maximum execution time exceeded
2020-11-18 18:13:04 (200) API_INT-thread-2 F78993F9DBE8A0105E65C3AF299619CB txid=3f8993f9dbe8 WARNING *** WARNING *** #314140 [REST API] RESTAPIProcessor : Handling exception com.glide.sys.TransactionCancelledException: Transaction cancelled: maximum execution time exceeded
2020-11-18 18:13:04 (200) API_INT-thread-2 F78993F9DBE8A0105E65C3AF299619CB txid=3f8993f9dbe8 WARNING *** WARNING *** #314140 [REST API] RESTAPIProcessor : Unknown exception RESTRuntimeException:com.glide.sys.TransactionCancelledException: Transaction cancelled: maximum execution time exceededDetail: Transaction cancelled: maximum execution time exceeded
2020-11-18 18:13:04 (200) API_INT-thread-2 F78993F9DBE8A0105E65C3AF299619CB txid=3f8993f9dbe8 DEBUG: #314140 [REST API] RESTAPIProcessor : End of Request Processing
2020-11-18 18:13:04 (200) API_INT-thread-2 F78993F9DBE8A0105E65C3AF299619CB txid=3f8993f9dbe8 DEBUG: #314140 [REST API] RESTAPIProcessor : REST Request Processing time total_time_to_now_micro_secs=60052941
2020-11-18 18:13:04 (200) API_INT-thread-2 F78993F9DBE8A0105E65C3AF299619CB txid=3f8993f9dbe8 SEVERE *** ERROR *** Problem processing asynchronous servlet request

Cause

The most probable cause of this error would be that the execution of the query takes longer than what is defined in the Transaction Quota Rule. Once the set limit is reached, the instance will cancel any transaction in violation of the policy and notifies the user of the cancellation, and similar messages are also seen in the logs.

Resolution

To fix this issue, we would need to adjust the “Maximum Duration (seconds)” of the Transaction Quota Rules related to the type of request.


To adjust these values please navigate to System Definition > Transaction Quota Rules. Since this is an inbound REST transaction, one of the below Transaction Quota Rule will need to be modified depending on the type of REST API:

REST Import Set API request timeout
Prevents inbound REST Import Set API transactions from running for longer than 60 seconds.

REST Table API request timeout
Prevents inbound REST Table API transactions from running for longer than 60 seconds.

REST Aggregate API request timeout
Prevents inbound REST Aggregate API transactions from running for longer than 60 seconds.

REST Attachment API request timeout
Prevents inbound REST Import Set API transactions from running for longer than 60 seconds.


Additional Information

Please note that there is also a catch-all Transaction Quota Rule for REST and JSON.

REST and JSON Catch All
Default Rule for all REST and JSON transactions.

This would be the last quota rule to come into consideration for an inbound REST transaction to ServiceNow.