Database has table X and tables An, Bn, Cn, Dn that inherits from X.
Process 1 queries periodically data from X.
Process 2 updates data in child tables. For example, to update tables An and Bn it creates new tables Am and Bm, loads data into them, locks in access exclusive An, Bn, drops An and Bn and alters Am and Bm to inherit X.
The problem is that when process 1 execute query (for example select * from X
) it locks tables An, Bn, Cn, Dn in shared mode, and order of locking is unknown. If process 1 locks Bn, then process 2 locks An we have deadlock.
Are there any info about order of locking tables in queries in postgresql (without explicit locking)? Or may be other solutions are possible?