Pivotal Knowledge Base

Follow

Query Fails giving Error: stack depth limit exceeded

Environment

 Product  Version
 Pivotal Greenplum (GPDB)  4.3.x
 OS  RHEL 6.x
 Others  

Symptom

Query Fails with Error when it has reached Greenplum's maximum stack depth limit. 

Error Message:

ERROR: stack depth limit exceeded 
HINT: Increase the configuration parameter "max_stack_depth", after ensuring the platform's
stack depth limit is adequate.

Cause

Every OS has a limited set of stack size to prevent stack overuse. In Linux, you can set stack size by "ulimit -s" 

Crossing this limit may leave the system with "Segmentation Fault". To avoid such situation, Greenplum has its own limitation for the stack size which is always less than the OS limit. It is represented by GUC "max_stack_depth" 

Resolution

There are a couple of options that would resolve this error: 

1) GUC max_stack_depth can be set by a superuser within a session to run the query. Also, consider the option to rewrite the query or break it down to reduce the stack size utilization.

2) If multiple queries are reporting the error, the Admin User [gpadmin] should change the value at Cluster level using "gpconfig" utility. Test your system for this change in Dev environment before implementing in Production. 

**Note**: While changing values for max_stack_depth, make sure it is under the OS stack limit [ulimit -s]. For more information refer to max_stack_depth

 

Comments

Powered by Zendesk