0001-Add-logging-for-exceeded-parallel-worker-slot-limits.patch_v2_no_guc

text/plain

Filename: 0001-Add-logging-for-exceeded-parallel-worker-slot-limits.patch_v2_no_guc
Type: text/plain
Part: 0
Message: Re: Logging parallel worker draught
From fc71ef40f33f94b0506a092fb5b3dcde6de6d60a Mon Sep 17 00:00:00 2001
From: benoit <benoit.lobreau@dalibo.com>
Date: Tue, 2 May 2023 10:08:00 +0200
Subject: [PATCH] Add logging for exceeded parallel worker slot limits

Procude a log message when a backend attempts to spawn a parallel worker
but fails due to insufficient worker slots. The shortage can stem from
max_worker_processes, max_parallel_worker, or
max_parallel_maintenance_workers. The log message can help database
administrators and developers diagnose performance issues related to
parallelism and optimize the configuration of the system accordingly.
---
 src/backend/access/transam/parallel.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index b26f2a64fb..c60d1bd739 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -630,6 +630,11 @@ LaunchParallelWorkers(ParallelContext *pcxt)
 		pcxt->nknown_attached_workers = 0;
 	}
 
+	if (pcxt->nworkers_launched < pcxt->nworkers_to_launch)
+			ereport(LOG,
+				(errmsg("Parallel Worker draught during statement execution: workers spawned %d, requested %d",
+					pcxt->nworkers_launched, pcxt->nworkers_to_launch)));
+
 	/* Restore previous memory context. */
 	MemoryContextSwitchTo(oldcontext);
 }
-- 
2.39.2