Re: Possible problem with shm_mq spin lock

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Possible problem with shm_mq spin lock
Date: 2014-10-25 23:17:51
Message-ID: 20141025231751.GN5790@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2014-10-26 08:52:42 +1100, Haribabu Kommi wrote:
> I am thinking of a possible problem with shm_mq structure spin lock.
> This is used for protecting the shm_mq structure.
>
> During the processing of any code under the spin lock, if the process
> receives SIGQUIT signal then it is leading to a dead lock situation.
>
> SIGQUIT->proc_exit->shm_mq_detach->try to acquire spin lock. The spin
> lock is already took by the process.
>
> It is very dificult to reproduce the problem as because the code under
> the lock is very minimal.
> Please let me know if I missed anything.

I think you missed the following bit in postgres.c:

/*
* quickdie() occurs when signalled SIGQUIT by the postmaster.
*
* Some backend has bought the farm,
* so we need to stop what we're doing and exit.
*/
void
quickdie(SIGNAL_ARGS)
{
...
/*
* We DO NOT want to run proc_exit() callbacks -- we're here because
* shared memory may be corrupted, so we don't want to try to clean up our
* transaction. Just nail the windows shut and get out of town. Now that
* there's an atexit callback to prevent third-party code from breaking
* things by calling exit() directly, we have to reset the callbacks
* explicitly to make this work as intended.
*/
on_exit_reset();
..

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Haribabu Kommi 2014-10-26 00:22:12 Re: Possible problem with shm_mq spin lock
Previous Message Steve Singer 2014-10-25 22:18:07 logical decoding - reading a user catalog table