Per database connection limit buglet

Started by Dave Pageover 17 years ago9 messagesbugs
Jump to latest
#1Dave Page
dpage@pgadmin.org

It's possible to set a per-database connection limit of < -1, which seems bogus:

gator:~ dpage$ /usr/local/pgsql84/bin/psql -p 5433 postgres
psql (8.4devel)
Type "help" for help.

postgres=# create database test with connection limit = -999;
CREATE DATABASE
postgres=# select datname, datconnlimit from pg_database;
datname | datconnlimit
-----------+--------------
template1 | -1
template0 | -1
postgres | 50
foo | 45
test | -999
(5 rows)

8.3 seems similarly afflicted - I haven't tested any further back.

--
Dave Page
EnterpriseDB UK: http://www.enterprisedb.com

#2Heikki Linnakangas
heikki.linnakangas@enterprisedb.com
In reply to: Dave Page (#1)
Re: Per database connection limit buglet

Dave Page wrote:

It's possible to set a per-database connection limit of < -1, which seems bogus:

Yeah. That's simple to fix, but I'm having trouble wordsmithing the
error message. This is what I came up with:

invalid connection limit %d (must be -1, meaning no limit, or greater)

Any better suggestions?

I also note that you can set it to INT_MAX, while max_connections is
limited to INT_MAX/4, but I'm inclined to leave that alone.

8.3 seems similarly afflicted - I haven't tested any further back.

Hmm, I don't think this should be backported, since it doesn't cause any
actual problems. We'd just risk breaking people's scripts that use
-999 to mean "no limit". (they will be broken when they upgrade to 8.4
anyway, of course, but that's fine)

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

#3Dave Page
dpage@pgadmin.org
In reply to: Heikki Linnakangas (#2)
Re: Per database connection limit buglet

On Mon, Jan 26, 2009 at 12:26 PM, Heikki Linnakangas
<heikki.linnakangas@enterprisedb.com> wrote:

Dave Page wrote:

It's possible to set a per-database connection limit of < -1, which seems
bogus:

Yeah. That's simple to fix, but I'm having trouble wordsmithing the error
message. This is what I came up with:

invalid connection limit %d (must be -1, meaning no limit, or greater)

Any better suggestions?

Perhaps drop the 'meaning no limit'? Less helpful perhaps (but that's
what the manual is for), but it sounds better

--
Dave Page
EnterpriseDB UK: http://www.enterprisedb.com

#4tomas@tuxteam.de
tomas@tuxteam.de
In reply to: Heikki Linnakangas (#2)
Re: Per database connection limit buglet

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, Jan 26, 2009 at 02:26:05PM +0200, Heikki Linnakangas wrote:

Dave Page wrote:

It's possible to set a per-database connection limit of < -1, which seems
bogus:

Yeah. That's simple to fix, but I'm having trouble wordsmithing the error
message. This is what I came up with:

invalid connection limit %d (must be -1, meaning no limit, or greater)

Any better suggestions?

Maybe

invalid connection limit %d (must be positive or -1, for "unlimited")

Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD4DBQFJfbYXBcgs9XrR2kYRApUkAJ9V/aYLn37zyDeS7dqTwZqgLfqoVgCYokPR
52vaXe/OrDwdKFlN4vElSQ==
=XS2a
-----END PGP SIGNATURE-----

#5Heikki Linnakangas
heikki.linnakangas@enterprisedb.com
In reply to: tomas@tuxteam.de (#4)
Re: Per database connection limit buglet

tomas@tuxteam.de wrote:

On Mon, Jan 26, 2009 at 02:26:05PM +0200, Heikki Linnakangas wrote:

Dave Page wrote:

It's possible to set a per-database connection limit of < -1, which seems
bogus:

Yeah. That's simple to fix, but I'm having trouble wordsmithing the error
message. This is what I came up with:

invalid connection limit %d (must be -1, meaning no limit, or greater)

Any better suggestions?

Maybe

invalid connection limit %d (must be positive or -1, for "unlimited")

Hmm, that sounds better, but it can also be 0.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

#6tomas@tuxteam.de
tomas@tuxteam.de
In reply to: Heikki Linnakangas (#5)
Re: Per database connection limit buglet

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, Jan 26, 2009 at 03:16:37PM +0200, Heikki Linnakangas wrote:
[...]

Maybe
invalid connection limit %d (must be positive or -1, for "unlimited")

Hmm, that sounds better, but it can also be 0.

Oops. "nonnegative", then. Creeping unreadability, again?

Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFJfcmLBcgs9XrR2kYRAtQRAKCCG5Zn6mKfzFJyRPeanH80t0a7HgCeL5r8
rzthpyajTrBYEppMnZFPeC4=
=NqZ9
-----END PGP SIGNATURE-----

#7Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Heikki Linnakangas (#2)
Re: Per database connection limit buglet

Heikki Linnakangas wrote:

Dave Page wrote:

It's possible to set a per-database connection limit of < -1, which seems bogus:

Yeah. That's simple to fix, but I'm having trouble wordsmithing the
error message. This is what I came up with:

invalid connection limit %d (must be -1, meaning no limit, or greater)

Split it up:

errmsg("invalid connection limit %d"),
errdetail("Limit must be a non-negative number, or -1 for no limit.")

or maybe

errdetail("Valid values are -1 for no limit, or a non-negative number.")

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

#8Tom Lane
tgl@sss.pgh.pa.us
In reply to: Heikki Linnakangas (#2)
Re: Per database connection limit buglet

Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:

Dave Page wrote:

It's possible to set a per-database connection limit of < -1, which seems bogus:

Yeah. That's simple to fix, but I'm having trouble wordsmithing the
error message. This is what I came up with:

Why does it need to be anything except GUC's standard "invalid value"
message? I really don't believe that this case is worth making
translators deal with an additional string.

regards, tom lane

#9Heikki Linnakangas
heikki.linnakangas@enterprisedb.com
In reply to: Tom Lane (#8)
Re: Per database connection limit buglet

Tom Lane wrote:

Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:

Dave Page wrote:

It's possible to set a per-database connection limit of < -1, which seems bogus:

Yeah. That's simple to fix, but I'm having trouble wordsmithing the
error message. This is what I came up with:

Why does it need to be anything except GUC's standard "invalid value"
message? I really don't believe that this case is worth making
translators deal with an additional string.

I guess. The message in guc.c seems a bit cumbersome, though, so I did
create a new message for it. It's now simply "invalid connection limit: %d".

The check was missing from per-user connection limits, fixed that too.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com