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 1i2HAn-0001K6-Ct for pgsql-committers@arkaria.postgresql.org; Mon, 26 Aug 2019 15:44:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i2HAk-0005F9-Uv for pgsql-committers@arkaria.postgresql.org; Mon, 26 Aug 2019 15:44:46 +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 1i2HAk-0005F1-JF for pgsql-committers@lists.postgresql.org; Mon, 26 Aug 2019 15:44:46 +0000 Received: from mail-yw1-xc43.google.com ([2607:f8b0:4864:20::c43]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i2HAh-0004xV-37 for pgsql-committers@lists.postgresql.org; Mon, 26 Aug 2019 15:44:45 +0000 Received: by mail-yw1-xc43.google.com with SMTP id z63so6779701ywz.9 for ; Mon, 26 Aug 2019 08:44:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=from:subject:to:references:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=WO3sRaz3YKJMMbvIXFJHd6lT6oh96uhAR2m/HbV8RUw=; b=FtZEzc1eB+VxOmjkjPI3N1rxshV9dCdiWCxor3Zs3RPvOdDLrIwsKRvi6Fc7/QnOhM J4fn1hWI8AhqFE/D28SMcoshVugdyBzInvK7KqvaspLWAUxYAndipKy+GPKhnVgVfr6I z9UhKnSZn5N5GoB8LpzL4dV8GJWxqcpXEtSbxF7XiZ4t0Db9TRlEjuMxJbx0aaKv4Qu0 DCA0xLTia93vXcH2qAK43FyDHWwK3PjdcF3O00rxJ2ctdCHYtTnKgSAvaz0tOxgUkdVN y8X3MLrW9jqlNh1GLDqPVZZuVozFwjx4BMhXgPBWWq+XhlVW4dmwugCwORmpFD1h+ksN 4YoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-transfer-encoding:content-language; bh=WO3sRaz3YKJMMbvIXFJHd6lT6oh96uhAR2m/HbV8RUw=; b=b6CVR0IEJgv3TwAv0iZG8JhPwAl1Th9+zKpDZOOpNIeIe1wx4s4yF3dCV3sKu7BCIh asMSmr8lTgXmVWbncJmKoWbj3Z5vk/1fXJUarqHMHIDcyV3vS1gIlN1OLQhnMUasMIUd lsTShbDtTP2IPRsZSCd75+5yYtPZ5IBacSZ4f0unB6wrVRVu0qSt+DBiFIodOoO4qfjT 3BeVgj2qnxpYpwhmCkVy0mG1tP1Y2I1FWJHDrnaf+cPuQ+Zf/0x/LVCA4KfyfpkBq1Kn wVdxSmL8KllP3JwydT0lHLvfPYXne8Kg/NTNKhMqB3mTk6mcsefsYgLWvCjyikzw73Fc gq/g== X-Gm-Message-State: APjAAAWoXl609lDr822yduyf3MH9upk76NiHY9EBWBnurxIUALiLjyNk yQk+nUdvCUV1VU+34zRGsbM9NCLUpNVjzjkCVt2TLEb3ZhgPlct0ysTJ10AuYpiR2cyTOmRsc5b wMDh3wn/aLpDOyQxPookvUWnP3rjjkxX8vdMgSDp1w914RHiq90gWEoLlA08vcDuggLIz5fVEfF cpBJDMVQQEuaZ9i2o/2885OSU8KoI= X-Google-Smtp-Source: APXvYqyqwrDCmpIwX/g/KPxVlt4KrAzYtFRNRn69sjbqJTVF48nX9BZjQqJQ6AfnCla51TylI1IuDg== X-Received: by 2002:a81:802:: with SMTP id 2mr13612866ywi.163.1566833811754; Mon, 26 Aug 2019 08:36:51 -0700 (PDT) Received: from [192.168.10.146] (99-10-92-30.lightspeed.rlghnc.sbcglobal.net. [99.10.92.30]) by smtp.gmail.com with ESMTPSA id 143sm2619538ywi.81.2019.08.26.08.36.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Aug 2019 08:36:51 -0700 (PDT) From: Andrew Dunstan X-Google-Original-From: Andrew Dunstan Subject: Re: pgsql: Fix error handling of vacuumdb and reindexdb when running out of To: Michael Paquier , pgsql-committers@lists.postgresql.org References: <20190826054000.GE7005@paquier.xyz> Openpgp: preference=signencrypt Autocrypt: addr=andrew.dunstan@2ndQuadrant.com; prefer-encrypt=mutual; keydata= xsBNBE7KWFkBCAClridxur2AIc7eW2AR7izbfp3EnNefie2HbLF0izW5Ik5UjX2HBXBx4syI gY6b0ugohXrr274+baoAlvSbq6cAoQuEVrk5IZFzt20b1Xkx65FwGSEj526yiKLocqkJceSq Xr9xcA5SGY+FZv441chh5SU92v4q6z+6LPpoHOh97ptAVXZYNTtU0LevyvD5lja0TzbvJm6C eFXitJfnm1pLEr0DGJCR/iUOl/N62Kh4855zZC7NHIjQHPOvV5Stz/l5ilDhvGVk+xkXFPys SjZoUr1rXhYLpiyi5sR0X9FHXT0KnGuz1F5ERO7ZTLSSQ6fJwPj6gOk9K+vvoKvoeql5ABEB AAHNL0FuZHJldyBEdW5zdGFuIDxhbmRyZXcuZHVuc3RhbkAybmRRdWFkcmFudC5jb20+wsCY BBMBAgBCAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAUJDyV6hBYhBOQ+WEYd/Hy/RGkV pZn6f8tZ/DuBBQJcH/EVAhkBAAoJEJn6f8tZ/DuB7BEH/iDWZEbVft2m2MT6SPjARzTupt/l xLLZ/Cl6n2US2hov5+fBbnR5xvECk/YCOfG9ICvKNlpFjceqNLRKStd8cmndnI+kDw91uNM2 hpL4aJMeW65XCHvqXlOLSwv5chBpXz9NG7FMaJ+q+59sWEWjcTNmjXgkEHn53y+1pc7nSLDe cr5ZI1aB3nGXRm1SoDY5PYZkUKMykW+YBZwgcs/Q5tRaE+siN7DKbz8E628+PerwAkmHPVXN MdJFD6gs4S0gDFA8IxcyIwZU2v4By+brzcJ9Se3FK5BYxBDHtaYZxgSrJAvOUOrLIZPQTQfL TtnVs3C3JTfrxCH1ceHtnA6dRuTOwE0ETspYWQEIANGc4zQULOxhbqO2dyD51YhqCNRmm9oK Waqf+wmW4tpDe/VVcxAnNizd4LWCHfzpb5cHAtGkOPePMfzWVf6nvdF7d3eglbtf59+zG7O7 llV0xSSoFiieQBsrGvqDInXYX/4mRRXMtyhM353/tixC9RWLs1oofyYmCPPXXY7h9R7en3B8 BoVrRFcdzlIY/NFNhFGW/9dkEiGjgna2Rk6e15kln4ZvFBWUg23p93w/pqXcxY6+k/8TEk+C 4R+M6w7o2PLGOjdZ+kPiUcw5H85zf/yZJwQXzisXaNduwWB6Vads9YC9dj6kPR1c4VGRqAaY L++LAEOqrlvm2TvqQqZRtnEAEQEAAcLAZQQYAQIADwIbDAUCXA6fpAUJDyV6xAAKCRCZ+n/L Wfw7geU4B/9vFFsVmWxerDWgNjyiK80zIPmlw/iwdUlU6FIu0JWLMg4093kvxBs7RMZV9hBq n3ekBvD4IvFsVLJrw9qzSI2FH3UeYy5WXpEs01Ppia60NOlvRDqXbryzuvfe+iYo6bVP3Ikr TPTNYL/BePUTD2DPvSI82SbGTyzuA7SJv6NRqqQDMIy1fU6KyQFLmQJp/QJyhKWzm9jWh8ee w8jVaoMY0Kbq5N7RqisEx1Lu/Iw646UphdYzQNymf+kbiU5Kf4I6DhzV8w9sie1Bo1juNj3I c5/fFJsmxljbnaDbXPcnFsur1Oo9mIHFakgWgOBMuxoWfjONiLjjLh/9+ZIqSSLX Message-ID: Date: Mon, 26 Aug 2019 11:36:50 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20190826054000.GE7005@paquier.xyz> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Content-Language: en-MW List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 8/26/19 1:40 AM, Michael Paquier wrote: > 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 >> >> 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. >> >> 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=jacana&dt=2019-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.) Looks OK. cheers andrew -- Andrew Dunstan https://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services