Re: limiting connections per user/database

From: Neil Conway <neilc(at)samurai(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Petr Jelínek <pjmodos(at)parba(dot)cz>, pgsql-patches(at)postgresql(dot)org
Subject: Re: limiting connections per user/database
Date: 2005-06-27 06:35:14
Message-ID: 42BF9E22.10404@samurai.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Tom Lane wrote:
> I'm still missing what the exact "bug fix" is here.

The bug is:

- a backend starts up and sends the collector a BESTART message. For the
sake of clarity, suppose that the backend is the first and only backend
connected to its database.

- the stats collector receives the BESTART message and records the
existence of the backend via pgstat_add_backend(). In current sources,
it does not initialize the entry for the backend's database in pgStatDBHash.

- the stats collector then decides to write out the stats file. Since
there is no pgStatDBHash entry for the backend's database, we don't
write out anything for it.

- 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.

This can be seen in current sources with a fresh initdb and default
postgresql.conf settings: connect to a database, and do select * from
pg_stat_database.

-Neil

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Stephen Frost 2005-06-27 06:40:36 Re: Users/Groups -> Roles
Previous Message Stephen Frost 2005-06-27 06:29:49 Users/Groups -> Roles