Re: [HACKERS] TODO Done. Superuser backend slot reservations - Mailing list pgsql-patches

From Neil Conway
Subject Re: [HACKERS] TODO Done. Superuser backend slot reservations
Date
Msg-id 87znva75wx.fsf@mailbox.samurai.com
Whole thread Raw
List pgsql-patches
"Nigel J. Andrews" <nandrews@investsystems.co.uk> writes:
>     Reserve last few process slots for super-user if max_connections
>     reached

Another minor coding suggestion:

+     /*
+      * Check a normal user hasn't connected to a superuser reserved slot.
+      * Do this here since we need the user information and that only happens
+      * after we've started bringing the shared memory online. So we wait
+      * until we've registered exit handlers and potentially shut an open
+      * transaction down for an as safety conscious rejection as possible.
+      */
+     if (!superuser() && MyBackendId > MaxBackends - ReservedBackends)
+         elog(ERROR, "Normal user limit exceeded");

This would be more efficient if you placed the superuser() test after
the BackendId test, as it is both more expensive to evaluate and more
likely to be true.

Cheers,

Neil

--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [ODBC] PostgreSQL 7.2.1 and Sun's C compiler under Solaris8
Next
From: Neil Conway
Date:
Subject: pg_locks cleanup