Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XlhFC-0005DY-N9 for pgsql-bugs@arkaria.postgresql.org; Tue, 04 Nov 2014 16:46:10 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XlhFB-0003s9-H5 for pgsql-bugs@arkaria.postgresql.org; Tue, 04 Nov 2014 16:46:09 +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 1XlhFA-0003rw-GN; Tue, 04 Nov 2014 16:46:08 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XlhF7-0003tA-Ap; Tue, 04 Nov 2014 16:46:06 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id sA4GjpaG019836; Tue, 4 Nov 2014 11:45:51 -0500 From: Tom Lane To: pgsql-hackers@postgreSQL.org cc: marc@bloodnok.com, pgsql-bugs@postgreSQL.org Subject: Re: BUG #11867: Strange behaviour with composite types after resetting database tablespace In-reply-to: <2382.1415070484@sss.pgh.pa.us> References: <20141104014957.23088.78673@wrigleys.postgresql.org> <2382.1415070484@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Mon, 03 Nov 2014 22:08:04 -0500" Date: Tue, 04 Nov 2014 11:45:51 -0500 Message-ID: <19835.1415119551@sss.pgh.pa.us> X-Pg-Spam-Score: -2.5 (--) 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 I wrote: > However: at no point in this sequence did we flush the original catalog > blocks out of shared buffers. Therefore, a read of the database's > pg_class or pg_type at this point is likely to find the previous states of > those pages (pre-composite-type-drop) as valid, matching entries, so that > we skip reading the up-to-date page contents back from disk. > A quick fix for this would be to issue DropDatabaseBuffers during > movedb() BTW, I wondered whether the exact same hazard didn't exist for ALTER TABLE SET TABLESPACE. At first glance it looks bad, because ATExecSetTableSpace doesn't forcibly drop old shared buffers for the moved table either. Closer examination says we're safe though: * The buffers will be dropped during smgrdounlink at end of transaction, so you could only be at risk if you moved a table, modified it, and moved it back in a single transaction. * A new relfilenode will be assigned during each movement. * When assigning a relfilenode during the move-back, we'd be certain to choose a relfilenode different from the original one, because the old relation still exists on-disk at this point. So it's safe as things stand; but this seems a bit, um, rickety. Should we insert a DropRelFileNodesAllBuffers call into ATExecSetTableSpace to make it safer? It's kind of annoying to have to scan the buffer pool twice, but I'm afraid that sometime in the future somebody will try to get clever about optimizing away the end-of-transaction buffer pool scan, and break this case. Or maybe I'm just worrying too much. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs