Skip site navigation (1) Skip section navigation (2)

Re: Detecting libpq connections improperly shared via fork()

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Daniel Farina <daniel(at)heroku(dot)com>
Subject: Re: Detecting libpq connections improperly shared via fork()
Date: 2012-10-03 22:14:02
Message-ID: 201210040014.03220.andres@2ndquadrant.com (view raw or flat)
Thread:
Lists: pgsql-hackers
On Thursday, October 04, 2012 12:08:18 AM Daniel Farina wrote:
> It would be fantastic for libpq to somehow monitor use of a connection
> from multiple PIDs that share a parent and deliver an error indicating
> what is wrong.  Unfortunately detecting that would require either a
> file or some kind of shared memory map, AFAIK, and I don't know how
> keen anyone is on accepting that patch.  So, may I ask: how keen is
> anyone on accepting such a patch, and under what conditions of
> mechanism?
Hm. An easier version of this could just be storing the pid of the process 
that did the PQconnectdb* in the PGconn struct. You can then check that 
PGconn->pid == getpid() at relatively few places and error out on a mismatch. 
That should be doable with only minor overhead.

I have seen such errors before...

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


In response to

Responses

pgsql-hackers by date

Next:From: Daniel FarinaDate: 2012-10-03 22:16:14
Subject: Re: Detecting libpq connections improperly shared via fork()
Previous:From: Phil SorberDate: 2012-10-03 22:09:00
Subject: Re: PQping command line tool

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group