Skip to content

GORDA

Sections
Personal tools
You are here: Home » Community » Mailing Lists

Bug in PostgreSQL patched code

View: New views
1 Messages — Rating Filter:   Alert me  

Bug in PostgreSQL patched code

by Donald Fraser :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The following code change submitted in your patch for PostgreSQL is incorrect.
File: src/backend/utils/init/postinit.c

...
static void
ShutdownPostgres(int code, Datum arg)
{
      if (!IsBootstrapProcessingMode() && code == 0) {
           shutdownTrigger = true;
           StartTransactionCommand();
           ExecTriggerSpecial(TRIGGER_TYPE_SHUTDOWN);
           CommitTransactionCommand();
      }
...

The reason it is incorrect is that during a shut down of the backend via a
FATAL or PANIC failure, the user will almost certainly be in a transaction of
some sort and therefore "StartTransactionCommand();" fails with message:
"StartTransactionCommand: unexpected state STARTED".

I am not sure of the correct solution here but I assume you are expecting no
transaction abort state when "code == 0". I think a better solution would be:

if (!IsBootstrapProcessingMode() && code == 0 &&
    !IsTransactionOrTransactionBlock()) {

Regards
Donald Fraser.



LightInTheBox - Buy quality products at wholesale price
 



Powered by Plone

This site conforms to the following standards: