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

Re: reserved_superuser_connections tweak

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: reserved_superuser_connections tweak
Date: 2002-11-21 05:32:23
Message-ID: 7570.1037856743@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-patches
Neil Conway <neilc(at)samurai(dot)com> writes:
> --=-=-=
> There's no point counting the # of empty backend slots (which requires
> grabbing an LWLock) unless
>         (a) the # of reserved slots is > 0
>         (b) the current user is not a superuser
> Thus, we can sometimes get away without grabbing the lock

Good point.  OTOH, superuser() is not necessarily a cheap function
either.  If the user's pg_shadow row hasn't yet been loaded into the
SHADOWSYSID cache, it will provoke a catalog row fetch cycle, which will
cost *way* more than one measly LWLock.  I'm not sure whether that's
likely to be the case though --- have you checked where that cache entry
first gets loaded in a typical startup?

A more serious problem with this code, now that I look at it, is that it
is risking a catalog fetch cycle outside of any transaction.  That is a
Big No-No.

			regards, tom lane

In response to

pgsql-patches by date

Next:From: Tom LaneDate: 2002-11-21 06:39:18
Subject: Re: documentation for reserved_superuser_connections
Previous:From: Neil ConwayDate: 2002-11-20 22:18:41
Subject: Re: documentation for reserved_superuser_connections

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