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 1hLXTu-0005Ke-W6 for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Apr 2019 18:27:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hLXTt-0007Pt-Ei for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Apr 2019 18:27:53 +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 1hLXTt-0007Pk-61 for pgsql-hackers@lists.postgresql.org; Tue, 30 Apr 2019 18:27:53 +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 1hLXTm-0005QE-EX for pgsql-hackers@lists.postgresql.org; Tue, 30 Apr 2019 18:27:52 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 0E72F79A; Tue, 30 Apr 2019 14:27:43 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 30 Apr 2019 14:27:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=3XSFEGLR8dZh8elWoJO0mjn247S c9XKWjrCdXYL34j4=; b=RqVGU7zN8jKZtZeMXSNzNx2psJNGusV7c8896etA9PW I9D5iBRD94AacvifpXUOxmeayVYywByWVpZwtTZQrtPqAkz6oPadMEco0fsm54ck JgLP4ZVgvNIQcyrSkFCIu5AbIpJ2ow99EGsKuxksXzMexZAWI541GgLWs57b7Zx0 +n0j7jBhRni++KBIcLVHo4YfKpj9Yjm5cDmDYyLaVZZk0Y35KOiccFPLpFMOnCMn XVeHrFRmYD9Sm7LgqPax/b/LCIIdPiE30Ku/IK6ZURxaNQr1/wItduqzcChQPZUm luQPtZLnkdp3gu764eusDlivxBmdxd4OS+m6IC+1AkQ== 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=fm2; bh=3XSFEG LR8dZh8elWoJO0mjn247Sc9XKWjrCdXYL34j4=; b=LeLYftmvuUFiav5uTm8nUr t2Pz5HH4kRMbHK/X2YBrvyc+hoCgjhXjRKgxoit6fco9J+nKnje1A/2kbuflB2h+ uZN64fUbnPEZkXjbn52Jw/DurESzpuLQ0gC9Fd54CxhnG8qhGpZP8gKlLft0jGpi WybzgStdwgGDrS/qCrx+TXQF8ikpt/6peVOxGfwaNPkq9nu7zEIVZo3UMielMQ7+ QMcA8KA7040bqETX3/bd6liIEh7Bu66i1x0o7kStUKBpAmloJ9acTCudAR7k0ztp IsW4Kz/q3GNbX6e86kC7jkUZUUZM6V57qcl04rCrWwlNylhsUonM0zCQIPT+Vhbw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrieehgdeiiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecukfhppeelke drvddutddrudegtddrudejudenucfrrghrrghmpehmrghilhhfrhhomheprghnughrvghs segrnhgrrhgriigvlhdruggvnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from intern.anarazel.de (c-98-210-140-171.hsd1.ca.comcast.net [98.210.140.171]) by mail.messagingengine.com (Postfix) with ESMTPA id 9EF65E44B6; Tue, 30 Apr 2019 14:27:42 -0400 (EDT) Date: Tue, 30 Apr 2019 11:27:41 -0700 From: Andres Freund To: Tom Lane Cc: Michael Paquier , Postgres hackers Subject: Re: REINDEX INDEX results in a crash for an index of pg_class since 9.6 Message-ID: <20190430182741.s6o7mo5ebmgxxi5x@alap3.anarazel.de> References: <12189.1556575627@sss.pgh.pa.us> <20190429220924.lfptluzkujb26y2n@alap3.anarazel.de> <20190430030342.jmbgnih4q3cdoufz@alap3.anarazel.de> <26051.1556599053@sss.pgh.pa.us> <26528.1556599820@sss.pgh.pa.us> <20190430070552.jzqgcy4ihalx7nur@alap3.anarazel.de> <30579.1556639470@sss.pgh.pa.us> <20190430173457.pg6i6urvevse5jer@alap3.anarazel.de> <29546.1556647550@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <29546.1556647550@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2019-04-30 14:05:50 -0400, Tom Lane wrote: > Andres Freund writes: > > It's the lock-upgrade problem I theorized about > > upthread. ReindexIndex(), via RangeVarCallbackForReindexIndex(), takes a > > ShareLock on pg_class, and then goes on to upgrade to RowExclusiveLock > > in RelationSetNewRelfilenode(). But at that time another session > > obviously can already have the ShareLock and would also want to upgrade. > > Hmm. Note that this is totally independent of the deadlock mechanism > I reported in my last message on this thread. Yea :( > > I'm not sure it's worth fixing this. > > I am not sure it's even *possible* to fix all these cases. I think it's worth fixing the most common ones though. It sure sucks that a plain REINDEX TABLE pg_class; isn't safe to run. > Even if we could, it's out of scope for v12 let alone the back branches. Unfortunately agreed. It's possible we could come up with a fix to backpatch after maturing some, but certainly not before the release. > I think the only practical solution is to remove those reindex tests. > Even if we ran them in a script with no concurrent scripts, there'd > be risk of failures against autovacuum, I'm afraid. Not often, but > often enough to be annoying. > Possibly we could run them in a TAP test that configures a cluster > with autovac disabled? Hm. Would it be sufficient to instead move them to a non-concurrent test group, and stick a BEGIN; LOCK pg_class, ....; COMMIT; around it? I think that ought to make it safe against autovacuum, and theoretically there shouldn't be any overlapping pg_class/index updates that we'd need to wait for? This is a pretty finnicky area of the code, with obviously not enough test coverage. I'm inclined to remove them from the back branches, and try to get them working in master? Greetings, Andres Freund