Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1etRFH-0000Tv-Ih for pgsql-bugs@arkaria.postgresql.org; Wed, 07 Mar 2018 05:04:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1etRFE-00055c-Aq for pgsql-bugs@arkaria.postgresql.org; Wed, 07 Mar 2018 05:04:04 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1etRFD-00054B-Ho; Wed, 07 Mar 2018 05:04:04 +0000 Received: from new1-smtp.messagingengine.com ([66.111.4.221]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1etRF9-0003p6-6z; Wed, 07 Mar 2018 05:04:01 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id D30DCC81; Wed, 7 Mar 2018 00:03:57 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute4.internal (MEProxy); Wed, 07 Mar 2018 00:03:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=wh6vxGUAdjhhAJnJdTiSPgLH8jOarLt2kmkKuAXxmhU=; b=kUJFfHYF Hmy2hhVt4u37OM1u0jxPu3tuXVSU4NNPxZb9lh89wnOfvNoFOk5OOxC8vES/Wru5 fyTNgrZXPqhgo+TFk2ilwR0lXjxPQhFHFMfr40XtIez6wvgHsuMUy5V5nu4vTsyY O3tBkr/+NsdxpubtDA1fz9zKuA3AJqjrxXgzUtvNR/5U/ui1d2Tdf43bqLqkb3yU k3Oc87wIcFc1oFFT5BpNuEN9BnOL6zgeD9kgSptE349VN1GjRmgOlrjh4tgom5wG 9YLQcGlo/nzET9Nqrnbei5lqE0xQfxDpwD1wk2uCH1ZqOcHhyFLAEH8JCRwV8XZ/ OdYhY0fQD0515Q== 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-sender :x-me-sender:x-sasl-enc; s=fm2; bh=wh6vxGUAdjhhAJnJdTiSPgLH8jOar Lt2kmkKuAXxmhU=; b=EaJUnqHnKWGbTxJjWmZkGFuxOpD6l4e9OpdjW6tCGlnp/ 1TWe9yJ3BweywJXAotPf/AQJKYUYLs5k09GpLZpClye8rWljsMNTvOZ9ZpBOyzjZ CMmRRHNmFbgxjZOpZisMibbNTgzSZb0601BDEZcWaAMuYkejVYIH0pRENddnEHTs AhFn0knjEPSURS8vBDpAx7Ec9H4/3df/DX8ZApGa11gLj84c1y9oRQuoz0kHGp2h himR4RWSXTZmNTXzxPpYiFplYEo2ixxNv9y8UG1v8dNw2rtlFAiDDHWF/fZAlWoI ZepMA1SMkKtQ30ZSf3JXVaC5dXeR6fSSpcdwMRcCA== X-ME-Sender: Received: from paquier.xyz (c137162.net61215.cablenet.ne.jp [61.215.137.162]) by mail.messagingengine.com (Postfix) with ESMTPA id CC1D37E498; Wed, 7 Mar 2018 00:03:53 -0500 (EST) Date: Wed, 7 Mar 2018 14:03:45 +0900 From: Michael Paquier To: "Bossart, Nathan" Cc: Andres Freund , Michael Paquier , Masahiko Sawada , Robert Haas , Lyes Ameddah , Tomas Vondra , "pgsql-hackers@postgresql.org" , "pgsql-bugs@postgresql.org" Subject: Re: BUG #14941: Vacuum crashes Message-ID: <20180307050345.GA3095@paquier.xyz> References: <32F4B778-292B-41AF-891A-497B8127CD59@amazon.com> <5B80D67E-A664-495A-A0BE-CEA847676164@amazon.com> <20180109042720.GG76418@paquier.xyz> <4B232BD7-A97D-4461-81E6-28A49764B60E@amazon.com> <20180110025331.GE336@paquier.xyz> <20180110231442.GA22983@paquier.xyz> <20180304001252.5sxn3glccnu5qxjm@alap3.anarazel.de> <7327B413-1A57-477F-A6A0-6FD80CB5482D@amazon.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="IS0zKkzwUGydFO0o" Content-Disposition: inline In-Reply-To: <7327B413-1A57-477F-A6A0-6FD80CB5482D@amazon.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --IS0zKkzwUGydFO0o Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Mar 05, 2018 at 09:55:13PM +0000, Bossart, Nathan wrote: > On 3/3/18, 6:13 PM, "Andres Freund" wrote: >> I was working on committing 0002 and 0003, when I noticed that the >> second patch doesn't actually fully works. NOWAIT does what it says on >> the tin iff the table is locked with a lower lock level than access >> exclusive. But if AEL is used, the command is blocked in >> >> static List * >> expand_vacuum_rel(VacuumRelation *vrel) >> ... >> /* >> * We transiently take AccessShareLock to protect the syscache lookup >> * below, as well as find_all_inheritors's expectation that the caller >> * holds some lock on the starting relation. >> */ >> relid =3D RangeVarGetRelid(vrel->relation, AccessShareLock, false); >> >> ISTM has been added after the patches initially were proposed. See >> http://git.postgresql.org/gitweb/?p=3Dpostgresql.git;a=3Dcommit;h=3D19de= 0ab23ccba12567c18640f00b49f01471018d >> >> I'm a bit disappointed that the tests didn't catch this, they're clearly >> not fully there. They definitely should test the AEL case, as >> demonstrated here. >=20 > Sorry about that. I've added logic to handle ACCESS EXCLUSIVE in v6 of 0= 002, > and I've extended the tests to cover that case. Hm, yes. I have also let those patches rot a bit myself. Sorry for that. >> Independent of that, I'm also concerned that NOWAIT isn't implemented >> consistently with other commands. Aren't we erroring out in other uses >> of NOWAIT? ISTM a more appropriate keyword would have been SKIP >> LOCKED. I think the behaviour makes sense, but I'd rename the internal >> flag and the grammar to use SKIP LOCKED. >=20 > Agreed. I've updated 0002 to use SKIP LOCKED instead of NOWAIT. So, NOWAIT means "please try to take a lock, don't wait for it and issue an error immediately if the lock cannot be taken". SKIP_LOCKED means "please try to take a lock, don't wait for it, but do not issue an error if the lock cannot be taken and move on to next steps". I agree that this is more consistent. + if (!(options & VACOPT_SKIP_LOCKED)) + relid =3D RangeVarGetRelid(vrel->relation, AccessShareLock, false); + else + { + relid =3D RangeVarGetRelid(vrel->relation, NoLock, false); Yeah, I agree with Andres that getting all this logic done in RangeVarGetRelidExtended would be cleaner. Let's see where the other thread leads us to: https://www.postgresql.org/message-id/20180306005349.b65whmvj7z6hbe2y%40ala= p3.anarazel.de + /* + * We must downcase the statement type for log message consistency + * between expand_vacuum_rel(), vacuum_rel(), and analyze_rel(). + */ + stmttype_lower =3D asc_tolower(stmttype, strlen(stmttype)); This blows up on multi-byte characters and may report incorrect relation name if double quotes are used, no? + /* + * Since autovacuum workers supply OIDs when calling vacuum(), no + * autovacuum worker should reach this code, and we can make + * assumptions about the logging levels we should use in the checks + * below. + */ + Assert(!IsAutoVacuumWorkerProcess()); This is a good idea, should be a separate patch as other folks tend to be confused with relid handling in expand_vacuum_rel(). + Specifies that VACUUM should not wait for any + conflicting locks to be released: if a relation cannot be locked + immediately without waiting, the relation is skipped Should this mention as well that no errors are raised, allowing the process to move on with the next relations? -- Michael --IS0zKkzwUGydFO0o Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlqfcrEACgkQnvQgOdby QH2UvQ//RfMpFsTHSgji/wBFTwF7hFJrHlxtrpO+jrjyEXvOMy6evmrTQwGdU4nZ ddNfZZ0XWyHRfSATrpbON0HZ4jp0dJZfCEFmEpuuGorxp1BrLSMIt1IpdRwJOvhV 7sxjMWSZpQruHK52mUxWiiNhbl/m1IYylvFiahV7xw5dmFKti6ySXfN/jfnNMcby /3XbYhwfMCSnTt+tvQmXlT4658K0R/mdLh0nMDqWWPAIpYNIFAsqbdCMmLAt1l/9 Y46GtmR7B4qS5bSzzyFpa2p8cc3ZGaGib1N0guedorA4nBaUQg+nqlHcVhoHeY/i UIr8cFP4Yw8Oi8GrYoYQaFQA7o1qgiHcaUUZmHPY7FRoq0XQMd89AHiMqxS99MpB ATdhOsS7CRps81+vt0+7EG/OSSXnuL/Q2m5FG0fJI0d1HhTLpgzg5r88NsgPi4E2 F4J293XrQGqaMBWRk9FcJc/iQhgu94EXqdsFKjJcsnrMIGKUosN+PZFoxxIFVRMX X2v1/PqGT06kQAQG0CZ2OIiuuVxGuSp5AtwwLYX5qluAK+YSrq12At2Dccs3ezLz XBE2Z+DdfD9IO2WD9HpjBiPw0wXbIj38N1IoiyWUmO6IOW/Mm44H9xHIeA7NxPtH Y+62pATmqN5Y1RHmezxQoDeJit2R3G9hjlGbkCRdLJpEyu8d6SU= =LZQH -----END PGP SIGNATURE----- --IS0zKkzwUGydFO0o--