pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: krc@hiper.dk
Subject: BUG #15394: Conflict between recovery thread and client queries on a hot standby replica
Date: Fri, 21 Sep 2018 09:21:12 +0000
Message-ID: <153752167223.14994.10205357154860231923@wrigleys.postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      15394
Logged by:          Kim Carlsen
Email address:      krc@hiper.dk
PostgreSQL version: 10.5
Operating system:   Ubuntu 18.04
Description:        

It seems that the recovery thread(streaming replication) and sql queries
against a postgresql hot standby can produce a deadlock.

If you have conflicting statements running on master and slave, you can end
up with queries on the slave waiting for locks of the recovery thread and
the recovery thread waiting for locks on the sql thread. The locks are never
resolved or any client aborted. This happens when using

max_standby_streaming_delay=-1

The manual does state that the recovery thread can wait indefinitely on a
SQL thread, but I would still expect dead locks to be detected and
handled.

How to reproduce:
- Setup pgsql master/slave with streaming replication
- On the slave "set max_standby_streaming_delay=-1"
- Start a thread on master that does the following
 
    BEGIN;
          CREATE OR REPLACE VIEW va AS SELECT 1;
          CREATE OR REPLACE VIEW vb as SELECT 2;
        COMMIT;
- Start multiple threads on the slave that does the following (with 5
workers running, a deadlock is produced within minutes)
    SELECT * FROM vb;
    SELECT * FROM va;
 

Expected behaviour:
  The 5 threads will continue be able to query the views va, vb

Observed behaviour:
  The 5 threads are blocked from reading the tables, after some time. They
are never allowed access to the views before all queries are aborted and
restarted. 

I have build a docker compose file to reproduce my observation.
https://github.com/kimc78/postgresql-slave-deadlock

This has been previously posted in pgsql-general and pgsql-bugs, my
apologies for repeating the request.



Message-ID: <153752167223.14994.10205357154860231923@wrigleys.postgresql.org>
Permalink:  ../153752167223.14994.10205357154860231923@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/153752167223.14994.10205357154860231923@wrigleys.postgresql.org

 · 

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: noreply@postgresql.org, krc@hiper.dk
  Subject: Re: BUG #15394: Conflict between recovery thread and client queries on a hot standby replica
  In-Reply-To: <153752167223.14994.10205357154860231923@wrigleys.postgresql.org>
  References: <153752167223.14994.10205357154860231923@wrigleys.postgresql.org>

* 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