Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 2B7A36335F9 for ; Sun, 20 Dec 2009 23:03:02 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 14164-05 for ; Mon, 21 Dec 2009 03:02:56 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.anarazel.de (mail.anarazel.de [217.115.131.40]) by mail.postgresql.org (Postfix) with ESMTP id B718A633686 for ; Sun, 20 Dec 2009 23:02:39 -0400 (AST) Received: from alap2.localnet (p549F5E2B.dip.t-dialin.net [84.159.94.43]) by mail.anarazel.de (Postfix) with ESMTPSA id 5B6D5448006; Mon, 21 Dec 2009 04:02:38 +0100 (CET) From: Andres Freund To: pgsql-hackers@postgresql.org, Simon Riggs Subject: Small Bug in GetConflictingVirtualXIDs Date: Mon, 21 Dec 2009 04:02:37 +0100 User-Agent: KMail/1.13.0 (Linux/2.6.32-andres-00908-g6ec22f9; KDE/4.3.80; x86_64; ; ) MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <200912210402.37850.andres@anarazel.de> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200912/1815 X-Sequence-Number: 152518 Hi Simon, Hi all, HS currently does the following in GetConflictingVirtualXIDs TransactionId pxmin = proc->xmin; /* * We ignore an invalid pxmin because this means that backend * has no snapshot and cannot get another one while we hold exclusive lock. */ if (TransactionIdIsValid(pxmin) && !TransactionIdFollows(pxmin, limitXmin)) { VirtualTransactionId vxid; GET_VXID_FROM_PGPROC(vxid, *proc); if (VirtualTransactionIdIsValid(vxid)) vxids[count++] = vxid; } The logic behind this seems fine except in the case of dropping a database. There you very well might have a open connection without an open snapshot. This leads to nice errors when youre connected to a database on the slave without having a in progress transaction while dropping the database on the primary: CET FATAL: terminating connection due to administrator command CET LOG: shutting down CET LOG: restartpoint starting: shutdown immediate CET FATAL: could not open file "base/16604/1259": No such file or directory CET CONTEXT: writing block 5 of relation base/16604/1259 CET WARNING: could not write block 5 of base/16604/1259 CET DETAIL: Multiple failures --- write error might be permanent. CET CONTEXT: writing block 5 of relation base/16604/1259 Should easily be solvable through an extra parameter for GetConflictingVirtualXIDs. Want me to prepare a patch? Andres