Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hzZZ0-0007Fm-8a for pgsql-bugs@arkaria.postgresql.org; Mon, 19 Aug 2019 04:46:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hzZYz-00010S-4G for pgsql-bugs@arkaria.postgresql.org; Mon, 19 Aug 2019 04:46:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hzZYy-00010L-T3 for pgsql-bugs@lists.postgresql.org; Mon, 19 Aug 2019 04:46:36 +0000 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hzZYw-0001is-2y for pgsql-bugs@lists.postgresql.org; Mon, 19 Aug 2019 04:46:36 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id DC1393B3; Mon, 19 Aug 2019 00:46:31 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 19 Aug 2019 00:46:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=R85+Sp4+eGaxe7lgT3o7p/rl+KE gFt13djPXGGsj7oc=; b=LlYDrLiMg/kdyyXtKvOc8pW1UO3VtjTXIJ7PqNLE7+P meUDP3LFDsxjr+jl3x5G8OC3k8Gg1Fw4geu/RI+2Q4KKbIxQHpk9SfQzeBe2JljX xks9MaYhUGQBJiykVWLLDnommZkOYRkjrZMS2HfpUvfV0gNKInKRWknfOspgPQqL 2j/MdN7JCCqA3GUogAyLgmQtx/D0EtL/Dl9oBKO55OpEcwaL53jnOpMTmxZahD1A jVaIu+pzT/CaRJEVMtRE4X/pOpx+6KKpto+T7FiOXV1E5RQpnnmRieb66JYwXyY6 Rn+RIP1zXCair8AvxdT1PuC7OplMIVBvh2G5oHM6TSg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=R85+Sp 4+eGaxe7lgT3o7p/rl+KEgFt13djPXGGsj7oc=; b=BFDy2HyFEh8h7znOcSy3BT m7fWeIBblqfEEdr8oZdXLNUB/drOoQFLOFXFQ53NoGhVlZIdwxMBdCdhkYpeucvn j/2X8pF445rsmJ0/rShTRSH2sINfjEkJHM6owNfouIY/d2b35P6lHKVqWJ4TzxEt cdZ7pDb5771ObmjqoxxdC6V5q66d54xHeSTAXICuiBe0eB8mjhk3awn7d1LlOYa2 vRhARCIgKhzCBoNH/mZAWr14WlTpvovO+F8jQWXCsHyBQ1yuxbLfY9JnHpYOFBnw csoXUmgj3dvc2iOdRtZR/rsL4aEDjrXXkOKlMKAmqHTAHGsaD0WBpd4UCYJCa7ww == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrudefkedgkeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdlvdefmdenucfjughrpeffhffvuffkfhggtggujgesghdtreertddt vdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprg hquhhivghrrdighiiiqeenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgnecu kfhppeduudekrddvgedurddvhedurdduheefnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmihgthhgrvghlsehprghquhhivghrrdighiiinecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from paquier.xyz (mp76f1fb99.ap.nuro.jp [118.241.251.153]) by mail.messagingengine.com (Postfix) with ESMTPA id 49B45380075; Mon, 19 Aug 2019 00:46:28 -0400 (EDT) Date: Mon, 19 Aug 2019 13:46:25 +0900 From: Michael Paquier To: Andres Freund Cc: Tom Lane , jungleboogie0@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15964: vacuumdb.c:187:10: error: use of undeclared identifier 'FD_SETSIZE' Message-ID: <20190819044625.GA18166@paquier.xyz> References: <15964-c1753bdfed722e04@postgresql.org> <24757.1566073861@sss.pgh.pa.us> <20190817210025.v4bblh4lhsxajmlj@alap3.anarazel.de> <6402.1566079145@sss.pgh.pa.us> <20190817224142.gq57z3cwt7c76dtk@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ADZbWkCsHQ7r3kzd" Content-Disposition: inline In-Reply-To: <20190817224142.gq57z3cwt7c76dtk@alap3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --ADZbWkCsHQ7r3kzd Content-Type: multipart/mixed; boundary="Kj7319i9nmIyA2yE" Content-Disposition: inline --Kj7319i9nmIyA2yE Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Aug 17, 2019 at 03:41:42PM -0700, Andres Freund wrote: > Heh, just discovered > https://www.postgresql.org/message-id/20160921171819.1357.29774%40wrigley= s.postgresql.org > from the same reporter, where we went through this before :/ Ugh. > On 2019-08-17 17:59:05 -0400, Tom Lane wrote: >> Andres Freund writes: >>> Most of the parallel code was move into bin/scripts/scripts_parallel.c - >>> but there's still the above error check. Seems like we ought to add a >>> ParallelSlotsMax() or such, and use that in the error check, rather than >>> check FD_SETSIZE directly? >>=20 >> Yeah, that would likely be cleaner than just responding to this directly. >=20 > I'll go and do that. Hm. I'd like to keep the dependency to select.h directly in scripts_parallel.c, so the ParallelSlotsMax sounds like a good thing to me so as FD_SETSIZE remains localized. That would give the attached which does not take care of pgbench, and there is an extra proposal in another part of this thread. Just looking at it now.. >> Indeed. I've confirmed the bug report on a local OpenBSD 6.4 build >> (clang 6.0.0), and with "make -k" I can see that reindexdb.c fails >> likewise. But this is unsurprising given that POSIX says that >> FD_SETSIZE is declared by sys/select.h. >=20 > Right. Okay, then the current code is broken in this sense. It was surprising to not see the buildfarm complain about that though. -- Michael --Kj7319i9nmIyA2yE Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="parallel-slot-fdlimit.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/bin/scripts/reindexdb.c b/src/bin/scripts/reindexdb.c index 14a4f4a91c..f93f7dd5fe 100644 --- a/src/bin/scripts/reindexdb.c +++ b/src/bin/scripts/reindexdb.c @@ -153,10 +153,10 @@ main(int argc, char *argv[]) pg_log_error("number of parallel jobs must be at least 1"); exit(1); } - if (concurrentCons > FD_SETSIZE - 1) + if (concurrentCons > ParallelSlotsMax()) { pg_log_error("too many parallel jobs requested (maximum: %d)", - FD_SETSIZE - 1); + ParallelSlotsMax()); exit(1); } break; diff --git a/src/bin/scripts/scripts_parallel.c b/src/bin/scripts/scripts_p= arallel.c index ffdc4e49ef..2b571a470e 100644 --- a/src/bin/scripts/scripts_parallel.c +++ b/src/bin/scripts/scripts_parallel.c @@ -94,6 +94,20 @@ select_loop(int maxFd, fd_set *workerset, bool *aborting) return i; } =20 +/* + * ParallelSlotsMax + * Returns the maximum number of parallel slots supported. + * + * Note that this is included here as FD_SETSIZE is declared in sys/select= =2Eh + * by POSIX. + */ +int +ParallelSlotsMax(void) +{ + /* leave some room for existing fds */ + return FD_SETSIZE - 10; +} + /* * ParallelSlotsGetIdle * Return a connection slot that is ready to execute a command. diff --git a/src/bin/scripts/scripts_parallel.h b/src/bin/scripts/scripts_p= arallel.h index ab82c5e6a9..dd625577c6 100644 --- a/src/bin/scripts/scripts_parallel.h +++ b/src/bin/scripts/scripts_parallel.h @@ -21,6 +21,8 @@ typedef struct ParallelSlot bool isFree; /* Is it known to be idle? */ } ParallelSlot; =20 +extern int ParallelSlotsMax(void); + extern ParallelSlot *ParallelSlotsGetIdle(ParallelSlot *slots, int numslot= s); =20 extern ParallelSlot *ParallelSlotsSetup(const char *dbname, const char *ho= st, diff --git a/src/bin/scripts/vacuumdb.c b/src/bin/scripts/vacuumdb.c index d81bfa3a6b..c5c38692ed 100644 --- a/src/bin/scripts/vacuumdb.c +++ b/src/bin/scripts/vacuumdb.c @@ -181,10 +181,10 @@ main(int argc, char *argv[]) pg_log_error("number of parallel jobs must be at least 1"); exit(1); } - if (concurrentCons > FD_SETSIZE - 1) + if (concurrentCons > ParallelSlotsMax()) { pg_log_error("too many parallel jobs requested (maximum: %d)", - FD_SETSIZE - 1); + ParallelSlotsMax()); exit(1); } break; --Kj7319i9nmIyA2yE-- --ADZbWkCsHQ7r3kzd Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl1aKaEACgkQnvQgOdby QH1Znw//dJMt0xdcSSeRdQKAu6gmbjZjdOWt8C713x0YOu/UZwI52mxzcW5bMc/v O4Ps1pCklEUe5l1ksp53I5/3v/6o4eMAq1t+5w8kMcRLbG2gxf2kOD4yfAevO3Kw ggRDuwHk+1TzRIN94DM3PItx2ypECYIZxTwo2kEFUYQLeJ6UEHQZmufM3w5sdZpt H1jYaCXzH87RRle6ahegyu4glIU8Q5uFT0dxOeJcOW6PbrD6eRkWzv3CjJthHOF0 yDWP4t9skeVUFOhr6V30PaGOrTmjgwlVimNs/aEpTglBQWt5MAycOOb73wpyWWPo OIfR5zyk2CkBssfOG/QNrxMYjlwL6qYrGeMw/tfk3GuakD0paPQwcg4GekuM+/78 ZvIC4JidGsjbbp6F0rdgJ2MYtLviL4QOwKf/yKe6nPnXHNXuyczvLJyBTnfnIp6V wuj+Pd6zFudW/uaDrrsw4fGOukXHqLPvl4+HjMdAS1wu6gGVEZu9xiDqG3gWyToF UR/FE83KmEEBZqpl2z8MCfClFasjgCLSmEpjLd+TGgZ0Lnw5aJ8uRLfTlf9sS/fa Rb2HBeQAxQY9a0UxY8dsImlp+u+mUc+ya5OdDWxtFJ75YnXSEAages/+PkTDQC4W GfyP+kf02N9D1XomSHV8oNi1IkejVDLhWnqYiWli0OaAJlQM2DA= =D4ZE -----END PGP SIGNATURE----- --ADZbWkCsHQ7r3kzd--