From f847875a1072e17eb98962260040926c2322228f Mon Sep 17 00:00:00 2001 From: martinko Date: Wed, 19 Feb 2014 13:44:58 +0100 Subject: [PATCH] londiste.create_partition: fixed to avoid deadlocks from concurrent workers --- sql/londiste/functions/londiste.create_partition.sql | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sql/londiste/functions/londiste.create_partition.sql b/sql/londiste/functions/londiste.create_partition.sql index 1a59e2ee..168aedfd 100644 --- a/sql/londiste/functions/londiste.create_partition.sql +++ b/sql/londiste/functions/londiste.create_partition.sql @@ -8,10 +8,10 @@ create or replace function londiste.create_partition( i_part_period text ) returns int as $$ ------------------------------------------------------------------------ --- Function: public.create_partition +-- Function: londiste.create_partition -- -- Creates inherited child table if it does not exist by copying parent table's structure. --- Locks parent table to avoid parallel creation. +-- Locks londiste.table_info table to avoid parallel creation of any partitions. -- -- Elements that are copied over by "LIKE x INCLUDING ALL": -- * Defaults @@ -91,7 +91,8 @@ begin fq_part := quote_ident(part_schema) || '.' || quote_ident(part_name); -- allow only single creation at a time, without affecting DML operations - execute 'lock table ' || fq_table || ' in share update exclusive mode'; + -- (changed from locking parent table to avoid deadlocks from concurrent workers) + execute 'lock table londiste.table_info in share update exclusive mode'; parent_oid := fq_table::regclass::oid; -- check if part table exists -- 2.39.5