pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: jarred@webriots.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #13844: Logical decoding bug with subxact + row locking
Date: Sun, 17 Jan 2016 21:37:26 -0500
Message-ID: <20160118023726.GF31313@momjian.us> (raw)
In-Reply-To: <20160105033249.1087.66040@wrigleys.postgresql.org>
References: <20160105033249.1087.66040@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

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  <bruce@momjian.us>        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



view thread (9+ messages)  latest in thread

Message-ID: <20160118023726.GF31313@momjian.us>
Permalink:  ../20160118023726.GF31313@momjian.us/
Also on:    postgresql.org/message-id/20160118023726.GF31313@momjian.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: bruce@momjian.us, jarred@webriots.com
  Subject: Re: BUG #13844: Logical decoding bug with subxact + row locking
  In-Reply-To: <20160118023726.GF31313@momjian.us>
  References: <20160105033249.1087.66040@wrigleys.postgresql.org> <20160118023726.GF31313@momjian.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox