pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrei Zhidenkov <andrei.zhidenkov@n26.com>
To: pgsql-general@lists.postgresql.org
Subject: Race condition while creating a new partition
Date: Fri, 15 Nov 2019 11:49:50 +0100
Message-ID: <FDFDBCC0-3AC5-44A7-A69F-D607CBA5A662@n26.com> (raw)

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.




view thread (7+ messages)  latest in thread

Message-ID: <FDFDBCC0-3AC5-44A7-A69F-D607CBA5A662@n26.com>
Permalink:  ../FDFDBCC0-3AC5-44A7-A69F-D607CBA5A662@n26.com/
Also on:    postgresql.org/message-id/FDFDBCC0-3AC5-44A7-A69F-D607CBA5A662@n26.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: andrei.zhidenkov@n26.com
  Subject: Re: Race condition while creating a new partition
  In-Reply-To: <FDFDBCC0-3AC5-44A7-A69F-D607CBA5A662@n26.com>
  References: <FDFDBCC0-3AC5-44A7-A69F-D607CBA5A662@n26.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox