Daniele Bortoluzzi <bortoluz@gmail.com> writes:
> If I cannot reproduce the error, what is the best way to catch the
> stack trace? Do I have to recompile with --enable-debug?
Yes, that would be the best thing. If you are using gcc there is no
harm in using --enable-debug all the time; it just makes the executable
files a bit bigger, there's no performance change.
Make sure the postmaster is started with "ulimit -c unlimited", else
the crash might not drop a core file. The core file will normally
appear in $PGDATA, but sometimes in a system-dependent special place
such as /cores/.
Once you've got a core file, do
$ gdb /path/to/postgres-executable /path/to/core-file
gdb> bt
... stack trace ...
gdb> quit
and send the whole output of gdb.
regards, tom lane