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

Re: why local_preload_libraries does require a separate directory ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tomas Vondra <tv(at)fuzzy(dot)cz>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: why local_preload_libraries does require a separate directory ?
Date: 2011-12-04 23:06:01
Message-ID: 19520.1323039961@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
Tomas Vondra <tv(at)fuzzy(dot)cz> writes:
> On 4.12.2011 22:16, Tom Lane wrote:
>> Um ... why would you design it like that?

> The backends are added to pg_stat_activity after the auth hook finishes,
> which means possible race conditions (backends executed at about the
> same time don't see each other in pg_stat_activity). So I use an
> exclusive lock that's acquired before reading pg_stat_activity and
> released after the pg_stat_activity is updated.
> That's the only thing the library loaded using local_preload_libraries
> does - it releases the lock.

That's an unbelievably ugly, and dangerous, kluge.  All you need is one
backend not loading the second library (and remember,
local_preload_libraries is user-settable) and you've just locked up the
system.

Why are you using pg_stat_activity for this anyway?  Searching the
ProcArray seems much safer ... see CountDBBackends for an example.

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Peter GeogheganDate: 2011-12-05 00:14:33
Subject: Re: Inlining comparators as a performance optimisation
Previous:From: Tom LaneDate: 2011-12-04 22:55:41
Subject: Re: planner fails on HEAD

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