Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kjl0o-0002ok-Mk for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Nov 2020 15:22:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kjl0n-000809-Kt for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Nov 2020 15:22:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kjl0n-000801-BU for pgsql-hackers@lists.postgresql.org; Mon, 30 Nov 2020 15:22:45 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kjl0g-0003qm-5K for pgsql-hackers@lists.postgresql.org; Mon, 30 Nov 2020 15:22:44 +0000 Received: from [192.168.1.70] (ppp91-79-61-252.pppoe.mtu-net.ru [91.79.61.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id A217C21C2FAC; Mon, 30 Nov 2020 18:22:35 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1606749755; bh=C6JhC9BwZAcUdtlmToYKacnlwIatQnSOqLAk4DKdMGs=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=epKUBO24MIi8/047rQh1bzogTL/Nq3rStkqstyKAWS4cqD2JRH54Mz+0KxB0Fkm8E +GgixpJMn/mIc3pSkQttxJPiyLcfexaVuQeiao5+RMPEQdb0YMcIC/0MWdluXFhyI4 8OemiMWrWvQuPKeMhfkLB1VYIlcjX5s99+wubDEg= Subject: Re: ALTER TABLE .. DETACH PARTITION CONCURRENTLY To: Alvaro Herrera , Amit Langote Cc: Pg Hackers References: <20201103235606.GA17495@alvherre.pgsql> From: Anastasia Lubennikova Message-ID: <450eebe2-ca1a-0a7a-0447-6eb67265b82f@postgrespro.ru> Date: Mon, 30 Nov 2020 18:22:35 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201103235606.GA17495@alvherre.pgsql> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 04.11.2020 02:56, Alvaro Herrera wrote: > Here's an updated version of this patch. > > Apart from rebasing to current master, I made the following changes: > > * On the first transaction (the one that marks the partition as > detached), the partition is locked with ShareLock rather than > ShareUpdateExclusiveLock. This means that DML is not allowed anymore. > This seems a reasonable restriction to me; surely by the time you're > detaching the partition you're not inserting data into it anymore. > > * In ExecInitPartitionDispatchInfo, the previous version always > excluded detached partitions. Now it does include them in isolation > level repeatable read and higher. Considering the point above, this > sounds a bit contradictory: you shouldn't be inserting new tuples in > partitions being detached. But if you do, it makes more sense: in RR > two queries that insert tuples in the same partition would not fail > mid-transaction. (In a read-committed transaction, the second query > does fail, but to me that does not sound surprising.) > > * ALTER TABLE .. DETACH PARTITION FINALIZE now waits for concurrent old > snapshots, as previously discussed. This should ensure that the user > doesn't just cancel the wait during the second transaction by Ctrl-C and > run FINALIZE immediately afterwards, which I claimed would bring > inconsistency. > > * Avoid creating the CHECK constraint if an identical one already > exists. > > (Note I do not remove the constraint on ATTACH. That seems pointless.) > > Still to do: test this using the new hook added by 6f0b632f083b. Status update for a commitfest entry. The commitfest is nearing the end and this thread is "Waiting on Author". As far as I see the last message contains a patch. Is there anything left to work on or it needs review now? Alvaro, are you planning to continue working on it? -- Anastasia Lubennikova Postgres Professional: http://www.postgrespro.com The Russian Postgres Company