Re: limiting connections per user/database - Mailing list pgsql-patches

From Tom Lane
Subject Re: limiting connections per user/database
Date
Msg-id 5986.1119880262@sss.pgh.pa.us
Whole thread Raw
In response to Re: limiting connections per user/database  (Neil Conway <neilc@samurai.com>)
List pgsql-patches
Neil Conway <neilc@samurai.com> writes:
> - when we read in the stats collector's stats file in a normal backend,
> there will be no pgStatDBHash entry for the backend's database.
> Therefore we'll read the beentry for the backend, and when we go to
> increment the n_backends for the corresponding dbentry, there will be no
> dbentry found (HASH_FIND at pgstat.c:2554), so n_backends won't be updated.

> - therefore we won't count the n_backends for the database correctly.

However, this could equally be fixed by replacing the hash_search call
at l. 2554 by pgstat_get_db_entry().  If your definition of "correct"
is that "a new backend can see at least one backend in its own database"
then this would be a more appropriate fix anyway, since there's a lag
between sending BESTART and seeing any result in the collector's output.

This isn't an argument against moving the responsibility for counting
n_backends into the collector, but as long as it's done in
pgstat_read_statsfile the proposed fix is pretty bogus.

            regards, tom lane

pgsql-patches by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: regexp_replace
Next
From: Michael Fuhr
Date:
Subject: PL/Python error checking