Errordata_stack_size exceeded error encountered in PostgreSQL

Source: Internet
Author: User
Tags postgresql psql what sql

Encountered an error in postgresql9.2, that is, in the stream replication mode, if you use Psql to access the standby machine, no matter what SQL statement executed, will be reported errordata_stack_size exceeded error.

The online search for this error, said because the stack to save the wrong information overflow. In postgresql.conf, this value defaults to 2M, which is supposed to be enough for 2M because one error report is not that big.

This value can not be arbitrarily set, it is related to the operating system. Under CentOS, the system defaults to 10M. Postgres This value can be set to a maximum of 9.5M.

I turned the value up and still reported the same error. It seems that the mistake is not here.

So, compile a debug version of PG, and then GDB follow up to see. After the standby is started PG, using the PS command to obtain the PID of the postgres process, using GDB's attach to trace the PID.

Run Psql, execute the SQL statement. But GDB could not trace:

Because in the standby state, Postgres will fork out the child process to process the query request:

24238 is the master process of the standby machine, and 24289 is the sub-process that it fork out to process the query request.

In debugging, you do not know the ID of the child process, this time, a parameter of GDB is very useful,

This follow-fork-mode can be set to two values, and child and parent can be set to children to track the sub-processes that the debugging process has forked out.

This is too convenient.

Run again, immediately follow the child process, found the function of the error:

The culprit is add_audit_logs, a function that is added to itself to record some audit information. However, Assigntransactionid is called in this function to get a new transaction ID, but in standby mode it is not allowed to create a transaction ID:

The Recoveryinprogress function returns True and then an error.

Next, Add_audit_logs will attempt to log this error message, then get the new transaction ID and raise the error above. Then add_audit_logs and record this error ...

The loop is dead until the stack that holds the error message is exhausted and the report stack overflows.

This error can be avoided by having the audit function fail in standby mode.

Errordata_stack_size exceeded error encountered in PostgreSQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.