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 1i27ji-0007Sr-I4 for pgsql-committers@arkaria.postgresql.org; Mon, 26 Aug 2019 05:40:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i27jg-0002K3-2z for pgsql-committers@arkaria.postgresql.org; Mon, 26 Aug 2019 05:40:12 +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 1i27je-0002IV-DA for pgsql-committers@lists.postgresql.org; Mon, 26 Aug 2019 05:40:11 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i27ja-0002xP-Mh for pgsql-committers@lists.postgresql.org; Mon, 26 Aug 2019 05:40:10 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 71B4221FDF for ; Mon, 26 Aug 2019 01:40:04 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 26 Aug 2019 01:40:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=HrVMjubmd98ozp/rdZyHNKn3hqj pTx9xPUK9Z30SFaw=; b=FWSGd//x/9g0VnhULlSzFuaBEBaNp3RfVL4R7qlsRjV DYYFbgd1bdR6y78+DU+zSaf30z9VoUT0otVJLgY+NqvmYoS+Jg4mbLkMcYMat2V7 MyA6Nlc3Wjd3zDqxVTjMaf+XedSycbBZVXNV2pIEKq6ONprf6PhEOwvlpIucHdTO x5CcgB8Saoc/xx59FQQalOqySjw6rvVlgTjIE3QTeHxJhI4SF5xqajvi/j1UMQKn Jk3fWSVEnarl3C9NuW0+2AS8B2Dx1PFpMvr+PtqIicTILxDSaqEEj8XSi6mc1Mo9 zTqKGP/gjUbjQz3Y+zdryWoszwOVFq+4v+5Ib6lWakA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=HrVMju bmd98ozp/rdZyHNKn3hqjpTx9xPUK9Z30SFaw=; b=PWfTyzaKRh7WddYZnkFOie bKaZ3SpddYn/yK/Xl5YsZS6iVoVx0/2t0ftAfJPIzkQd5XstMpXvHINkC4gaWbUq Dupy+fpRImFRxc3YhpJv76Z+xyUvmKeX5hHSB2U3nZIWO2Vn83xqvSwJGH8+O32H gNN+hSlATATEEXjxGTilNVlxztbHyOEVJZYtR1VmFROeZUklBywZa8WTF90H/onX pviCK8XK4wewBTNGLsgLnuPmoNmiEltqoyMiIkxmn4p1LTzt4yYOqGMiTdm5iMwZ ygoqr0k7efqkSIZJWIZCUqhkZU1FbYTrAJ90n462nf0o7o/NrUZDIlt4V2NW9wuA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrudehfedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdlfeehmdenucfjughrpeffhf fvuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcurfgrqhhu ihgvrhcuoehmihgthhgrvghlsehprghquhhivghrrdighiiiqeenucffohhmrghinhepph hoshhtghhrvghsqhhlrdhorhhgnecukfhppeduuddurddutddvrddukedtrddukeehnecu rfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiine cuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from paquier.xyz (ee0822lan1.rev.em-net.ne.jp [111.102.180.185]) by mail.messagingengine.com (Postfix) with ESMTPA id 2AA13D60063 for ; Mon, 26 Aug 2019 01:40:02 -0400 (EDT) Date: Mon, 26 Aug 2019 14:40:00 +0900 From: Michael Paquier To: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Fix error handling of vacuumdb and reindexdb when running out of Message-ID: <20190826054000.GE7005@paquier.xyz> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="NPukt5Otb9an/u20" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --NPukt5Otb9an/u20 Content-Type: multipart/mixed; boundary="NGIwU0kFl1Z1A3An" Content-Disposition: inline --NGIwU0kFl1Z1A3An Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Aug 26, 2019 at 02:17:06AM +0000, Michael Paquier wrote: > Fix error handling of vacuumdb and reindexdb when running out of fds >=20 > When trying to use a high number of jobs, vacuumdb (and more recently > reindexdb) has only checked for a maximum number of jobs used, causing > confusing failures when running out of file descriptors when the jobs > open connections to Postgres. This commit changes the error handling so > as we do not check anymore for a maximum number of allowed jobs when > parsing the option value with FD_SETSIZE, but check instead if a file > descriptor is within the supported range when opening the connections > for the jobs so as this is detected at the earliest time possible. >=20 > Also, improve the error message to give a hint about the number of jobs > recommended, using a wording given by the reviewers of the patch. jacana does not like that, and has reported an error for 9.6: https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=3Djacana&dt=3D2019-= 08-26 03%3A51%3A19 # Running: vacuumdb -zj2 postgres vacuumdb: vacuuming database "postgres" vacuumdb: too many jobs for this platform -- try 1 I am able to reproduce the problem locally, and the problem is that we don't declare FD_SETSIZE on Windows before winsock2.h in scripts_parallel.c (or vacuumdb.c in ~12) so all the Windows machines running TAP are going to complain on that. This matches with the same problem reported here https://www.postgresql.org/message-id/1248903114.6348.195.camel@lapdragon We have never done that before in vacuumdb.c, and because of that I think that with a high number of jobs we run into buffer overflows. The patch attached does the job on my end, any objections? There is an argument to do that in win32_port.h, but for now I'd rather take a safe path, or just do for the change in win32_port.h on HEAD. (Noticed the missing newline as well in the error string in back-branches... I'll address it at the same time.) -- Michael --NGIwU0kFl1Z1A3An Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="windows-fdset.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/bin/scripts/scripts_parallel.c b/src/bin/scripts/scripts_p= arallel.c index 55bda9044b..97435160e9 100644 --- a/src/bin/scripts/scripts_parallel.c +++ b/src/bin/scripts/scripts_parallel.c @@ -12,6 +12,10 @@ *------------------------------------------------------------------------- */ =20 +#ifdef WIN32 +#define FD_SETSIZE 1024 /* must set before winsock2.h is included */ +#endif + #include "postgres_fe.h" =20 #ifdef HAVE_SYS_SELECT_H --NGIwU0kFl1Z1A3An-- --NPukt5Otb9an/u20 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl1jcLAACgkQnvQgOdby QH1J/hAAmJAyRkbpmfO2lvUbyaY14gDMZm8REhwda2HnR6opgMBakEUAbBSK9vsG C+tEj7g8c/Q2J1ZifpkwkXrcvEqpcAci+Zr1AAEY6WJf54Vj49wRVrmpCiKGggb4 ABNuihQCpMGBmRzNIksUfN1xb7eeeliF6ouEqBq8/BX77HVwBYG7WVLWkAJ8FZs6 C0hM+pxfaD7nPfr5s54i3bmDDroq4/ZqbNN9VsbOgUQ7/U+VjC/fPWbEU66MUPAU D6PANKtEH6vxhVFWuBWjWcPmIjEDVTo4F6RTithKO6OYUHDDMSd6mTXgveJc+/07 AW5cNsIxOuobJsEsw3zE1rPmDKZGV6U1xbmEIOSlQ6mieL3fJ8wus2j1vIOG9YTg En/ItEKBzrIs0Oy7Q9D2pEMIvfsND70s+Fx5/2bpFCrXZp64+vkHnfibPr5MqMY7 eKFgEN/0RXHKnRqDQGQfI0uELOqqU9oLbceKgGCVOWznPgzcb8N4JI+B7YSe4Jfw GMEmVsNTP4YUnM60aAPFZ8xKj/4s7SPfYjyxmSO3RlQjdJSTOh9wuGi4KyVhQw8X gz71hLz/ycGu8lvgkh7HcNM6p1xXUP+C/7lioPSkK9f1E31RO2nF+x3U7pzzp9X9 E4p4Vgk5mZmvRzGIiPiy4diMd1BAYxokHomZLRzv58QuHppcxtM= =VXnh -----END PGP SIGNATURE----- --NPukt5Otb9an/u20--