[COMMITTERS] pgsql: Allow multiple bgworkers to be launched per postmasteriteration

Поиск
Список
Период
Сортировка
От Tom Lane
Тема [COMMITTERS] pgsql: Allow multiple bgworkers to be launched per postmasteriteration
Дата
Msg-id E1d3TNh-0004rk-OF@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Allow multiple bgworkers to be launched per postmaster iteration.

Previously, maybe_start_bgworker() would launch at most one bgworker
process per call, on the grounds that the postmaster might otherwise
neglect its other duties for too long.  However, that seems overly
conservative, especially since bad effects only become obvious when
many hundreds of bgworkers need to be launched at once.  On the other
side of the coin is that the existing logic could result in substantial
delay of bgworker launches, because ServerLoop isn't guaranteed to
iterate immediately after a signal arrives.  (My attempt to fix that
by using pselect(2) encountered too many portability question marks,
and in any case could not help on platforms without pselect().)
One could also question the wisdom of using an O(N^2) processing
method if the system is intended to support so many bgworkers.

As a compromise, allow that function to launch up to 100 bgworkers
per call (and in consequence, rename it to maybe_start_bgworkers).
This will allow any normal parallel-query request for workers
to be satisfied immediately during sigusr1_handler, avoiding the
question of whether ServerLoop will be able to launch more promptly.

There is talk of rewriting the postmaster to use a WaitEventSet to
avoid the signal-response-delay problem, but I'd argue that this change
should be kept even after that happens (if it ever does).

Backpatch to 9.6 where parallel query was added.  The issue exists
before that, but previous uses of bgworkers typically aren't as
sensitive to how quickly they get launched.

Discussion: https://postgr.es/m/4707.1493221358@sss.pgh.pa.us

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/e880df25ec35fab727678531d392403ce4226dd9

Modified Files
--------------
src/backend/postmaster/postmaster.c | 39 +++++++++++++++++++++----------------
1 file changed, 22 insertions(+), 17 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: [COMMITTERS] pgsql: doc PG10: add commit for transition table item
Следующее
От: Peter Eisentraut
Дата:
Сообщение: [COMMITTERS] pgsql: Fix typo in comment