Partitioning: CREATE OR REPLACE RULE freezes.

From: Gene <genekhart(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Partitioning: CREATE OR REPLACE RULE freezes.
Date: 2006-07-29 18:59:35
Message-ID: 430d92a20607291159y4dd29fbfxf7820d1ca5569928@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have created a function that I use to help automate the creation of
partition tables. Basically it:

1. Creates a new table inherited from the parent table (which is empty)
2. creates or replaces a sole rule on the parent table to insert into
the new table:

EXECUTE 'CREATE OR REPLACE RULE parent_insert_rule AS ON INSERT TO parent'
|| ' DO INSTEAD '
|| ' INSERT INTO ' || new_child_table;

3. Update constraints on last child table and new one for constraint exclusion.

It seems to work if I run it once or if I stop all inserts/updates to
the parent table. If I run it a second time it freezes during the
create or replace rule step. The parent table receives about 10
inserts per second so it must be some sort of deadlock but I don't
know where to start to fix the problem. I've tried locking the entire
table but that didn't seem to help. Any suggestions would be greatly
appreciated. I would prefer not to have to stop everything just to
create a new partition table.

Thanks,
--
Eugene Hart

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2006-07-29 19:10:48 Re: Auto Installation
Previous Message Habib Seifzadeh 2006-07-29 17:00:40 Auto Installation