Query Fails giving Error "stack depth limit exceeded"
search cancel

Query Fails giving Error "stack depth limit exceeded"

book

Article ID: 295590

calendar_today

Updated On:

Products

VMware Tanzu Greenplum

Issue/Introduction

Symptoms:

A query fails with an 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.

Environment


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 a 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 approaches 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 rewriting 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 a development environment before implementing the change into 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.