Обсуждение: Re: [HACKERS] TODO Done. Superuser backend slot reservations

Поиск
Список
Период
Сортировка

Re: [HACKERS] TODO Done. Superuser backend slot reservations

От
Neil Conway
Дата:
"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