v2-0002-Improve-failure-when-running-out-of-connections-w.patch
text/x-diff
Filename: v2-0002-Improve-failure-when-running-out-of-connections-w.patch
Type: text/x-diff
Part: 1
Patch
Format: format-patch
Series: patch v2-0002
Subject: Improve failure when running out of connections with parallel slots
| File | + | − |
|---|---|---|
| src/bin/scripts/scripts_parallel.c | 11 | 0 |
From 572eee4602d056b83a3d3907e0dfe795e04ffebe Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@paquier.xyz>
Date: Mon, 19 Aug 2019 14:08:20 +0900
Subject: [PATCH v2 2/2] Improve failure when running out of connections with
parallel slots
vacuumdb and reindexdb can fail with annoying errors if trying to open
more connections than what is supported, so, similarly to pgbench,
complain loudly if trying to do so.
---
src/bin/scripts/scripts_parallel.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/bin/scripts/scripts_parallel.c b/src/bin/scripts/scripts_parallel.c
index 2b571a470e..b124db0d48 100644
--- a/src/bin/scripts/scripts_parallel.c
+++ b/src/bin/scripts/scripts_parallel.c
@@ -160,6 +160,17 @@ ParallelSlotsGetIdle(ParallelSlot *slots, int numslots)
if (sock < 0)
continue;
+ /*
+ * Fail immediately if trying to use an index in an unsupported
+ * range. Doing a hard exit here is not beautiful, but that's
+ * not worth complicating the logic.
+ */
+ if (sock >= FD_SETSIZE)
+ {
+ fprintf(stderr, "too many client connections for select()\n");
+ exit(1);
+ }
+
FD_SET(sock, &slotset);
if (sock > maxFd)
maxFd = sock;
--
2.23.0.rc1