Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iVZAu-0004kr-8P for pgsql-general@arkaria.postgresql.org; Fri, 15 Nov 2019 10:50:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iVZAt-00014y-1m for pgsql-general@arkaria.postgresql.org; Fri, 15 Nov 2019 10:49:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iVZAs-0000zB-Fr for pgsql-general@lists.postgresql.org; Fri, 15 Nov 2019 10:49:58 +0000 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iVZAo-00042G-EV for pgsql-general@lists.postgresql.org; Fri, 15 Nov 2019 10:49:57 +0000 Received: by mail-wr1-x431.google.com with SMTP id r10so10467055wrx.3 for ; Fri, 15 Nov 2019 02:49:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=n26.com; s=google; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=wRCt3h/bYED4KmARPu8BanjfwJxYdaoojtO2sss0iSI=; b=FZHyO0YsnId6V8Dnp69/1lBYnL4C7+qWomhlVOLQtDex/3We2Nkd7+vSbiN8KlC+h7 gNqquIMvsG5WBv+fdJ1JloLmniVtOCRVDoqRTWx9+n94XrP0gjFvoZ4nWjBPyOwcsDKe Nb93ShqDiPrdmGD2O1PE/LDzBBRImw5aGFmBNKgc3/rh8w+Dcx5BZ7T2kD3lskJAPcx4 dsqdvbwrRQbO8jSmdGdZIV9ANqgstOvUyJUkijlzBgkWpc33dcdD8y8yCpMs/GgfVlvN dw6WDiTmk/vIq/HGN4XzsukTOs15PDKZUuQLFX/QyyblIASSzeJnMe050+RHkdzUYdyS poYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:to; bh=wRCt3h/bYED4KmARPu8BanjfwJxYdaoojtO2sss0iSI=; b=KCa0WDJ6Whlym5yNP3hs9zMcXQJomJjum+Vo9AuBnejzG8Ujc9axZ4s+rVFPZGjWOJ JLVdwixtN08/FzWgEtuu6Cbbm4fPOE/xc9UJ6Bu3EeHlbGIsukgmSv9VaUqDXPE1Y4us nc9bcPTGJk25RlC3S1zk4WlkqHfx5mksaJXUGW/fBy3wyZokK4+Sq1dDaiZ49yT/M+Eg rG2AYWcY3erusUx3pRPcQ7o0o94FUbNdKMmdGYmtsIXXyu3/Z915iCKVOhnTv2z13x+/ OZgdEcUNjyiv68IdqnYfFWEquzCtlf07/aDegd6t9QBSLNj5fkCJn21fHQXHhx+u30SM 4kQg== X-Gm-Message-State: APjAAAX1DOzHDP2g6bXAFwD3XHsUCQM+qUvSiQ6OJDXTLpCjovjlJlst UsubASnZY5S5YF7kO10Sc0LTbIyP9bzaW7JpavmrZAjGdpENiPRw5rACP+p7U8YQg4toGWnLWAl 1d+RAsDaB78tjpg0A+9yOtAa1E6vK3ISPeFj4bMghaBeO7hM+cWYFLPVpqjsW34JkFFn6m0Ppj6 AVxBiF9ymsT749kA== X-Google-Smtp-Source: APXvYqzrVXElGao8JExulKNb0+IrPCCyO58GI2gyNpNMCM5O00XRvPhPZQf8A3bH8qoSNRjAjLTGhw== X-Received: by 2002:adf:ea92:: with SMTP id s18mr638723wrm.327.1573814992280; Fri, 15 Nov 2019 02:49:52 -0800 (PST) Received: from [10.4.23.60] ([62.96.137.138]) by smtp.gmail.com with ESMTPSA id h124sm10299234wme.30.2019.11.15.02.49.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Nov 2019 02:49:51 -0800 (PST) From: Andrei Zhidenkov Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Race condition while creating a new partition Message-Id: Date: Fri, 15 Nov 2019 11:49:50 +0100 To: pgsql-general@lists.postgresql.org X-Mailer: Apple Mail (2.3445.104.11) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk We use this code in order to automatically create new partitions for a = partitioned table (Postgres 10.6): begin insert into ; exception when undefined_table then begin -- A concurrent txn has created the new partition exception when others then end; -- Insert data into the new partition insert into ; 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. =E2=80=94 With best regards, Andrei Zhidenkov.=