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 1kL6cE-0008Ea-Af for pgsql-hackers@arkaria.postgresql.org; Wed, 23 Sep 2020 15:23:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kL6cD-0002Ng-3Q for pgsql-hackers@arkaria.postgresql.org; Wed, 23 Sep 2020 15:23:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kL6cC-0002NX-OO for pgsql-hackers@lists.postgresql.org; Wed, 23 Sep 2020 15:23:28 +0000 Received: from mail-qt1-x842.google.com ([2607:f8b0:4864:20::842]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kL6c9-0007Rz-LQ for pgsql-hackers@lists.postgresql.org; Wed, 23 Sep 2020 15:23:28 +0000 Received: by mail-qt1-x842.google.com with SMTP id y11so148628qtn.9 for ; Wed, 23 Sep 2020 08:23:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=QpQ6+7kwqiMtC0VBPimRzkoaz+Sm8Xyv+41nbBNqzQc=; b=qfZ61TkXE4WuG6+StHVptLs5QlucAC16puBGOUP6RUOGFoBx64mk4732IRFcMxddja mt09lPl21EL8FoOS0CsplH8gQeKxdEDBvvnZJqnA8Qf9umhSUChF4BFNlEUowxhbJ98b UzzyzpTJ+ywij7bij2abiDZA9lh8D0OPeklTCqf/zZQdpnWgyPsFLLlG9XSOpJIYjLrH FmX+Pjifg9VVPWlsXTqMuWPxQzk3QzPSeHKuNvPjTekz7raQcK8qO7c7bPlfRvE4kgTJ 2whQtWtOtc5pSCsC6BnPCRM8bbOzfK9LObMwzuFxm3ubLdu5CLeVFDMpcrJiD0seYe2M C1Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=QpQ6+7kwqiMtC0VBPimRzkoaz+Sm8Xyv+41nbBNqzQc=; b=Wy3fApRU6/eFNv13GO1QLaVmRVs/SbSJJ58uGsRV55z8Oe8FyIC7JzrXGQY/eHp6BC gxg++kU6yAyXdWueW2iyeLGXj1UVzurwnSgamVXdB8jnguTNXI9bju9MgjmABZzBwEZR tKRTDk1pPL4GoAMGQxolhxti1EKRQNfqOCeYhpGB4mU0D3J/Vda0S0XFfkPSuhFvRPUY ylqKZvThq/Lyh6Jh+Y0v2nAuEVFltaxCE6tg5ytlvkKPOQKqYesQS/43PVyPJ1QkSNzb aDDpQGN/QXt2yh2GOmNF2v5kVaArdM+uz+fhc11y2k/dsKU+eWGZ7B7bN6XvEBqGDBvj J4bw== X-Gm-Message-State: AOAM5302O6CtXnDAuuquOGwZk2K0UnUQ8sLN4E4J6eHRVNNCMQFo6IIz uxQ6fOZmt6K+qPKhogJLkA9BLw== X-Google-Smtp-Source: ABdhPJytWCG5toN5tXq5FZPsBwSnf84gX/XzFcN+EKHyKRG20zYxKheqJp+FYWR5p1cgUNZ9bPs7Lg== X-Received: by 2002:ac8:66da:: with SMTP id m26mr552361qtp.111.1600874603879; Wed, 23 Sep 2020 08:23:23 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.19.148]) by smtp.gmail.com with ESMTPSA id c40sm34712qtb.72.2020.09.23.08.23.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 08:23:23 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id A69D52A19E5; Wed, 23 Sep 2020 12:23:21 -0300 (-03) Date: Wed, 23 Sep 2020 12:23:21 -0300 From: Alvaro Herrera To: Amit Langote Cc: Pg Hackers Subject: Re: ALTER TABLE .. DETACH PARTITION CONCURRENTLY Message-ID: <20200923152321.GA26342@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Sep-23, Amit Langote wrote: Hi Amit, thanks for reviewing this patch! > On Tue, Aug 4, 2020 at 8:49 AM Alvaro Herrera wrote: > I suspect that we don't really need this defensive constraint. I mean > even after committing the 1st transaction, the partition being > detached still has relispartition set to true and > RelationGetPartitionQual() still returns the partition constraint, so > it seems the constraint being added above is duplicative. Ah, thanks for thinking through that. I had vague thoughts about this being unnecessary in the current mechanics, but hadn't fully materialized the thought. (The patch was completely different a few unposted iterations ago). > Moreover, the constraint is not removed as part of any cleaning up > after the DETACH process, so repeated attach/detach of the same > partition results in the constraints piling up: Yeah, I knew about this issue (mentioned in my self-reply on Aug 4) and didn't worry too much about it because I was thinking I'd rather get rid of the constraint addition in the first place. > Noticed a bug/typo in the patched RelationBuildPartitionDesc(): > > - inhoids = find_inheritance_children(RelationGetRelid(rel), NoLock); > + inhoids = find_inheritance_children(RelationGetRelid(rel), NoLock, > + include_detached); > > You're passing NoLock for include_detached which means you never > actually end up including detached partitions from here. I fixed this in the version I posted on Sept 10. I think you were reading the version posted at the start of this thread. Thanks, -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services