We use this code in order to automatically create new partitions for a
partitioned table (Postgres 10.6):
begin
insert into <partitioned_table>;
exception when undefined_table then
begin
<create_unexistent_partition>
-- A concurrent txn has created the new partition
exception when others then end;
-- Insert data into the new partition
insert into <partitioned_table>;
end;
end;
As far as I understand we should always have a new partition created either in
current or in concurrent transaction but today we faced the problem when we
failed to insert data due to a partition nonexistence for a small period of
time. Have I missed something?
Thank you.
—
With best regards, Andrei Zhidenkov.