Can we increase max_stack_depth for our Postgres database?

Issue

You are running a query on your PostgreSQL database which shows the below error as it exceeds the max_stack_depth value:

Sequel::DatabaseError: PG::StatementTooComplex: ERROR:  stack depth limit exceeded
HINT:  Increase the configuration parameter "max_stack_depth" (currently 2048kB), after ensuring the platform's stack depth limit is adequate.
CAUSE: PG::StatementTooComplex: ERROR:  stack depth limit exceeded

Resolution

The max_stack_depth specifies the maximum safe depth of the server's execution stack. The default value is 2MB.

There is no way you can increase max_stack_depth on Heroku as it is tied with the server config(ulimit). They have to be kept in sync. If max_stack_depth > ulimit, a runaway function could crash the backend process (due to exceeding ulimit) and that would require restarting Postgres.

More information on max_stack_depth for PostgreSQL can be found in their docs: https://www.postgresql.org/docs/current/runtime-config-resource.html

Ask on Stack Overflow

Engage with a community of passionate experts to get the answers you need

Ask on Stack Overflow

Heroku Support

Create a support ticket and our support experts will get back to you

Contact Heroku Support
Terms of Service Privacy Cookies © 2020 Salesforce.com