Re: Race condition while creating a new partition

From: Andrei Zhidenkov <andrei(dot)zhidenkov(at)n26(dot)com>
To: Michael Lewis <mlewis(at)entrata(dot)com>
Cc: Justin <zzzzz(dot)graf(at)gmail(dot)com>, "pgsql general (pgsql-general(at)postgresql(dot)org)" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Race condition while creating a new partition
Date: 2019-12-17 08:41:47
Message-ID: 236D11BE-77E3-434A-AADD-A5E11DD73650@n26.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 partitions in advance and this procedure is only a backup mechanisum in case of something goes wrong. Now I think that the only 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(at)entrata(dot)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 actually needed? 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 the chance of deadlock completely.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2019-12-17 11:08:33 Re: weird long time query
Previous Message Kaijiang Chen 2019-12-17 02:58:17 weird long time query