|From:||Kim Rose Carlsen <krc(at)hiper(dot)dk>|
|Subject:||Conflict between recovery thread and client queries on a hot standby replica|
|Views:||Raw Message | Whole Thread | Download mbox | Resend email|
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
Which 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
CREATE OR REPLACE VIEW va AS SELECT 1;
CREATE OR REPLACE VIEW vb as SELECT 2;
- 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;
The 5 threads will continue be able to query the views va, vb
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.
|Next Message||Bruce Momjian||2018-09-09 22:22:24||Re: BUG #15376: Postgres sql 9.4.19 pg_upgrade stops with error The source cluster was not shut down cleanly.|
|Previous Message||Tom Lane||2018-09-09 20:10:51||Re: BUG #15367: Crash in pg_fe_scram_free when using foreign tables|
|Next Message||Ahmed, Nawaz||2018-09-10 04:19:37||RE: connection error|
|Previous Message||Kim Rose Carlsen||2018-09-09 20:00:04||Conflict between recovery thread and client queries on a hot standby replica|