Re: Race condition while creating a new partition - Mailing list pgsql-general

From Andrei Zhidenkov
Subject Re: Race condition while creating a new partition
Date
Msg-id 236D11BE-77E3-434A-AADD-A5E11DD73650@n26.com
Whole thread Raw
In response to Re: Race condition while creating a new partition  (Michael Lewis <mlewis@entrata.com>)
List pgsql-general
I’m creating a new partition for every second deliberately in order to faster reproduce a bug I have on the live
environment.In the live environment a new partitions are being created every one day. More to that, we create new
partitionsin advance and this procedure is only a backup mechanisum in case of something goes wrong. Now I think that
theonly way to avoid errors like this is to use explicit locking, I tried advisory locks and it worked well.  

> On 17. Dec 2019, at 00:06, Michael Lewis <mlewis@entrata.com> wrote:
>
> It looks like you are creating a partition for each minute of the day (when logs get inserted for a given minute at
least).Would it be at all reasonable to have an hourly or daily job which creates the partitions ahead of when they are
actuallyneeded? If partitions went unused in the recent past, you could also drop those if appropriate to your
workflow.I just wonder about doing the work just-in-time via 2+ connections vs doing it from a single process to avoid
thechance of deadlock completely. 




pgsql-general by date:

Previous
From: Michael Lewis
Date:
Subject: Re: Race condition while creating a new partition
Next
From: Steven Winfield
Date:
Subject: Row locks, SKIP LOCKED, and transactions