Thread: BUG #15064: Deadlock not detected on standby.

BUG #15064: Deadlock not detected on standby.

From
PG Bug reporting form
Date:
The following bug has been logged on the website:

Bug reference:      15064
Logged by:          Konstantin Evteev
Email address:      konst583@gmail.com
PostgreSQL version: 9.5.11
Operating system:   Debian GNU/Linux 8 (jessie)
Description:

Hello!
I have found a bug: deadlock not detected on standby.
It is actual for 
 PostgreSQL 9.5.11 on x86_64-pc-linux-gnu (Debian 9.5.11-1.pgdg80+1),
compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit
 PostgreSQL 9.4.16 on x86_64-unknown-linux-gnu (Debian 9.4.16-1.pgdg80+1),
compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit


And this is not actual for  
PostgreSQL 9.6.7 on x86_64-pc-linux-gnu (Debian 9.6.7-1.pgdg80+1), compiled
by gcc (Debian 4.9.2-10) 4.9.2, 64-bit
PostgreSQL 10.2 (Debian 10.2-1.pgdg80+1) on x86_64-pc-linux-gnu, compiled by
gcc (Debian 4.9.2-10) 4.9.2, 64-bit


May be this behavior needed to be backported to older versions 

-- on primary
--create table items(item_id int);
--create table options(item_id int, v1 text);


---- 1 st session - primary
  begin;
  alter table options add v2 int;

---- 2-nd session standby     
    begin;
    select * from items;

---- 1 st session - primary
  alter table items add a text;

on standby
  select * from options; 

deadlock not detected

in versions 9.6 and 10 - it's ok 
    
---------------------------------------
ERROR:  deadlock detected
LINE 1: select * from options;
                      ^
DETAIL:  Process 25364 waits for AccessShareLock on relation 17388 of
database 17384; blocked by process 25322.
Process 25322 waits for AccessExclusiveLock on relation 17385 of database
17384; blocked by process 25364.
HINT:  See server log for query details.
-----------------------------------------
--
Konstantin Evteev.