From: | Kim Rose Carlsen <krc(at)hiper(dot)dk> |
---|---|
To: | "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Conflict between recovery thread and client queries on a hot standby replica |
Date: | 2018-09-14 10:06:32 |
Message-ID: | VI1PR0502MB364676CBD1E77794D57A2A7CC7190@VI1PR0502MB3646.eurprd05.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-general |
I was getting no response in pgsql-general. So trying in pgsql-bugs instead. If there is something I need to do to make this more understandable, please let me know.
----
Hi
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
Best regards
Kim Carlsen
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2018-09-14 12:54:45 | Re: BUG #15384: dropping views and materialized views |
Previous Message | PG Bug reporting form | 2018-09-14 09:40:39 | BUG #15384: dropping views and materialized views |
From | Date | Subject | |
---|---|---|---|
Next Message | Chris Travers | 2018-09-14 10:10:47 | Re: Code of Conduct plan |
Previous Message | Ilya Kosmodemiansky | 2018-09-14 09:45:05 | Re: Code of Conduct plan |