Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XgvrO-0008T2-0m for pgsql-bugs@arkaria.postgresql.org; Wed, 22 Oct 2014 13:21:54 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XgvrN-0003LZ-G3 for pgsql-bugs@arkaria.postgresql.org; Wed, 22 Oct 2014 13:21:53 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XgvrL-0003Ic-IS for pgsql-bugs@postgresql.org; Wed, 22 Oct 2014 13:21:51 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XgvrI-0001dU-51 for pgsql-bugs@postgresql.org; Wed, 22 Oct 2014 13:21:49 +0000 Received: from intern.anarazel.de (unknown [194.224.59.233]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id E8151E0969; Wed, 22 Oct 2014 15:21:45 +0200 (CEST) Date: Wed, 22 Oct 2014 15:21:44 +0200 From: Andres Freund To: Tom Lane Cc: Michael Paquier , cg@osss.net, pgsql-bugs@postgresql.org Subject: Re: BUG #11638: Transaction safety fails when constraints are dropped and analyze is done Message-ID: <20141022132144.GE5790@alap3.anarazel.de> References: <20141010181433.25463.5856@wrigleys.postgresql.org> <20141010191401.GA18020@awork2.anarazel.de> <20141015051254.GC7242@alap3.anarazel.de> <20141015061815.GF7242@alap3.anarazel.de> <20648.1413943949@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20648.1413943949@sss.pgh.pa.us> X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 2014-10-21 22:12:29 -0400, Tom Lane wrote: > I don't much care for this patch. Aside from cosmetic issues like having > named the new argument backwards and failed to update the function header > comment that the patch largely invalidates, it seems to me to be likely > to have unforeseen side effects, in that there may now be assumptions > elsewhere that we don't force a pg_class update for this type of change. > The implications are particularly ticklish for pg_class itself... I'm unconvinced that that's a problem. We already do transactional updates of pg_class for stuff like CREATE INDEX - while the relation is *not* locked exclusively. And e.g. CLUSTER pg_class does transactional updates of pg_class itself, without problems afaics. The latter is under an exclusive lock admittedly. What's the problem you're suspecting? Even if it doesn't arrise to the level of data corruption, I suspect in many cases updating the stats nontransactionally in an later aborted transaction will surprise some users. The normal reason for doing a ANALYZE in a transaction is that you changed the data dramatically. > I think that a better answer is to continue to do this update > nontransactionally, but to not let the code clear relhasindex etc > if we're inside a transaction block. It is certainly safe to put > off clearing those flags if we're not sure that we're seeing a > committed state of the table's schema. That'd fix the corruption, so it'd certainly be an improvement. But I'm unconvinced that it's the best way forward. > An interesting question is whether it is ever possible for this function > to be told to *set* relhasindex when it was clear (or likewise for the > other flags). Offhand I would say that that should never happen, because > certainly neither VACUUM nor ANALYZE should be creating indexes etc. > Should we make it throw an error if that happens, or just go ahead and > apply the update, assuming that it's correcting somehow-corrupted data? It probably should at least LOG/WARN, to make it clear that things were in a bad shape. It might be helpful to allow VACUUM/ANALYZE to fix existing corrupted relhas* flags. Although there could already be existing corruption, in which case users might want to get alerted of that more aggressively. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs