From: Michael Paquier Date: Mon, 6 Jul 2026 02:37:36 +0000 (+0900) Subject: Emit a warning when io_min_workers exceeds io_max_workers X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9d1188f29865e66c4196578501e74e8c815fba8d;p=thirdparty%2Fpostgresql.git Emit a warning when io_min_workers exceeds io_max_workers When io_min_workers is set strictly higher than io_max_workers, the minimum has no effect since the pool will never grow past io_max_workers. Previously this was silently accepted, which could be confusing for users expecting at least io_min_workers workers to always be running. In order to avoid noise in the server logs, the following restrictions are in place: - The only process printing the WARNING is the IO worker with ID 0, on startup and reload, which is we know the only process always running when using IO workers. - At reload, the message shows only if one of the bounds has changed. Note that this commit reuses a log message updated by 7905416eef9b. Author: Baji Shaik Reviewed-by: Tristan Partin Reviewed-by: Kyotaro Horiguchi Discussion: https://postgr.es/m/CA+fm-RO_O7-XThg2qjj=ir35x9nOFbZYu07gttqAbM5T88QB4Q@mail.gmail.com --- diff --git a/src/backend/storage/aio/method_worker.c b/src/backend/storage/aio/method_worker.c index 63e34d66690..cf75b2816b7 100644 --- a/src/backend/storage/aio/method_worker.c +++ b/src/backend/storage/aio/method_worker.c @@ -662,6 +662,27 @@ pgaio_worker_can_timeout(void) return true; } +/* + * Emit a WARNING if io_min_workers > io_max_workers, since the worker + * pool will never exceed io_max_workers regardless of the minimum setting. + */ +static void +check_io_worker_gucs(void) +{ + /* Only do the check in one worker, to limit noise */ + if (MyIoWorkerId != 0) + return; + + if (io_min_workers > io_max_workers) + ereport(WARNING, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("\"%s\" (%d) should be less than or equal to \"%s\" (%d)", + "io_min_workers", io_min_workers, + "io_max_workers", io_max_workers), + errdetail("The I/O worker pool will not exceed \"%s\" (%d) workers.", + "io_max_workers", io_max_workers))); +} + void IoWorkerMain(const void *startup_data, size_t startup_data_len) { @@ -694,6 +715,8 @@ IoWorkerMain(const void *startup_data, size_t startup_data_len) /* also registers a shutdown callback to unregister */ pgaio_worker_register(); + check_io_worker_gucs(); + sprintf(cmd, "%d", MyIoWorkerId); set_ps_display(cmd); @@ -1011,9 +1034,20 @@ IoWorkerMain(const void *startup_data, size_t startup_data_len) if (ConfigReloadPending) { + int io_max_workers_prev = io_max_workers; + int io_min_workers_prev = io_min_workers; + ConfigReloadPending = false; ProcessConfigFile(PGC_SIGHUP); + /* + * Emit a WARNING if io_min_workers > io_max_workers. If no bound + * has changed, skip this to avoid too many log messages. + */ + if (io_min_workers_prev != io_min_workers || + io_max_workers_prev != io_max_workers) + check_io_worker_gucs(); + /* If io_max_workers has been decreased, exit highest first. */ if (MyIoWorkerId >= io_max_workers) break;