londiste.create_partition: fixed to avoid deadlocks from concurrent workers
authormartinko <gamato@users.sf.net>
Wed, 19 Feb 2014 12:44:58 +0000 (13:44 +0100)
committermartinko <gamato@users.sf.net>
Wed, 19 Feb 2014 12:44:58 +0000 (13:44 +0100)
sql/londiste/functions/londiste.create_partition.sql

index 1a59e2ee7b114f567df1ad8508e72dc1bd4d3390..168aedfdb2248df07713558d53f5b39ab8a7a6ff 100644 (file)
@@ -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