Re: Fwd: Bug#390730: postgresql-8.1: segfaults on huge litteral IN clauses - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Fwd: Bug#390730: postgresql-8.1: segfaults on huge litteral IN clauses
Date
Msg-id 19080.1160238217@sss.pgh.pa.us
Whole thread Raw
In response to Fwd: Bug#390730: postgresql-8.1: segfaults on huge litteral IN clauses  (Martin Pitt <mpitt@debian.org>)
Responses Re: Fwd: Bug#390730: postgresql-8.1: segfaults on huge  (Benoît Dejean <benoit@placenet.org>)
List pgsql-bugs
Martin Pitt <mpitt@debian.org> writes:
> I recently got the Debian bug report below, a server crash with huge
> IN clauses.

What this sounds like to me is someone increasing max_stack_depth
without understanding what he's doing.  You must make sure that
max_stack_depth is less than the "ulimit -s" setting the postmaster
is running under ... and not just a little bit less, you want a megabyte
or so of daylight in there.  Per the documentation:

max_stack_depth (integer)

      Specifies the maximum safe depth of the server's execution
      stack. The ideal setting for this parameter is the actual stack
      size limit enforced by the kernel (as set by ulimit -s or local
      equivalent), less a safety margin of a megabyte or so. The safety
      margin is needed because the stack depth is not checked in every
      routine in the server, but only in key potentially-recursive
      routines such as expression evaluation. Setting the parameter
      higher than the actual kernel limit will mean that a runaway
      recursive function can crash an individual backend process. The
      default setting is 2048 KB (two megabytes), which is
      conservatively small and unlikely to risk crashes. However, it may
      be too small to allow execution of complex functions.

So if the OP wants to use huge IN clauses, he has to both increase
max_stack_depth and adjust the ulimit that the postmaster runs under.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Martin Pitt
Date:
Subject: Fwd: Bug#390730: postgresql-8.1: segfaults on huge litteral IN clauses
Next
From: "Jean Tourrilhes"
Date:
Subject: BUG #2681: duplicate key violates unique constraint