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

From Neil Conway
Subject Re: limiting connections per user/database
Date
Msg-id 42BF9E22.10404@samurai.com
Whole thread Raw
In response to Re: limiting connections per user/database  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: limiting connections per user/database
List 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

pgsql-patches by date:

Previous
From: Stephen Frost
Date:
Subject: Users/Groups -> Roles
Next
From: Stephen Frost
Date:
Subject: Re: Users/Groups -> Roles