Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aKzhs-000755-N6 for pgsql-bugs@arkaria.postgresql.org; Mon, 18 Jan 2016 02:38:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aKzhs-0003K6-9o for pgsql-bugs@arkaria.postgresql.org; Mon, 18 Jan 2016 02:38:12 +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_SHA384:256) (Exim 4.84) (envelope-from ) id 1aKzhF-0002SG-IE for pgsql-bugs@postgresql.org; Mon, 18 Jan 2016 02:37:33 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1aKzhA-0003AC-GZ for pgsql-bugs@postgresql.org; Mon, 18 Jan 2016 02:37:32 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1aKzh8-0003dh-PD; Sun, 17 Jan 2016 21:37:26 -0500 Date: Sun, 17 Jan 2016 21:37:26 -0500 From: Bruce Momjian To: jarred@webriots.com Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #13844: Logical decoding bug with subxact + row locking Message-ID: <20160118023726.GF31313@momjian.us> References: <20160105033249.1087.66040@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160105033249.1087.66040@wrigleys.postgresql.org> User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -1.9 (-) 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 Tue, Jan 5, 2016 at 03:32:49AM +0000, jarred@webriots.com wrote: > The following bug has been logged on the website: > > Bug reference: 13844 > Logged by: Jarred Ward > Email address: jarred@webriots.com > PostgreSQL version: 9.4.5 > Operating system: Linux > Description: > > This is a pretty serious logical decoding bug that bit us pretty hard > in production. > > Run the following code: > > > ---------------------------------------------------------------------------- > CREATE TABLE foo(a SERIAL PRIMARY KEY, b TEXT); > > SELECT pg_create_logical_replication_slot('regression_slot', > 'test_decoding'); > > INSERT INTO foo (b) VALUES ('john'); > > BEGIN; > SELECT * FROM foo WHERE b = 'john' FOR UPDATE; > SAVEPOINT sp1; > INSERT INTO foo (b) VALUES ('jane'); > ROLLBACK TO SAVEPOINT sp1; > INSERT INTO foo (b) VALUES ('doe'); > END; > > SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, > NULL); > > ---------------------------------------------------------------------------- > > The last select above should return the decoded WAL, but instead it > returns: > > > ---------------------------------------------------------------------------- > ERROR: subxact logged without previous toplevel record > > ---------------------------------------------------------------------------- > > And the process is disconnected with no way to recover the replication > slot without dropping and recreating. > > If SELECT statement in the transaction is changed the following: > > > ---------------------------------------------------------------------------- > SELECT * FROM foo WHERE b = 'john' FOR UPDATE; > > ---------------------------------------------------------------------------- > > to remove the row level locking the correct decoded change set is > returned. I can confirm this behavior. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + As you are, so once was I. As I am, so you will be. + + Roman grave inscription + -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs