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 1jWNRN-0005Xp-AI for pgsql-hackers@arkaria.postgresql.org; Wed, 06 May 2020 17:02:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jWNRL-0003SN-JE for pgsql-hackers@arkaria.postgresql.org; Wed, 06 May 2020 17:02:35 +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 1jWNRL-0003Q9-8O for pgsql-hackers@lists.postgresql.org; Wed, 06 May 2020 17:02:35 +0000 Received: from mail-qv1-xf44.google.com ([2607:f8b0:4864:20::f44]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jWNRI-0006Ll-Cx for pgsql-hackers@lists.postgresql.org; Wed, 06 May 2020 17:02:34 +0000 Received: by mail-qv1-xf44.google.com with SMTP id di6so1098239qvb.10 for ; Wed, 06 May 2020 10:02:31 -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=rNrYXtfSDlSi50GmR0C14fvR4C5pWKKC/9fFXTE8zro=; b=wGD+/wr+4QNsAGQ5RzTuto7tOtOVP1MN5p/CE/broDKvkfgp5TRP/Xus08DW1H2RMU oru709Oxhhg6V1kHYFXYBJ2xzKDiHLlS4m0tQShlrJ+0gex3d/VZT+dk63P8kpdo7+lx 5FuWMnIssN3wRTsJiGPaCR7Ps3jkmUQOPE+gFpl0eXNPw7ibR6DvO81ivHJJO7aeicSJ +kdvoYrwCNDgYlKcjrrI2I+83hnGxqjDGzbyxoQSQIHPGZ/y6MbxFP982QPGBXBy7n34 5dsIGHvpx4f9zMqAPm7WhMg73REU/YjyNwpg6CEUVPkqoAqjqG/wyvDsUTy9YIlxCzAU m5tA== 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=rNrYXtfSDlSi50GmR0C14fvR4C5pWKKC/9fFXTE8zro=; b=L/CcORvSSAZxhEa/Rr/4IvRwmbCG04kDQa62cOKNaC2JNuVlKA9+3mb0fZfI5rDCht /8Xn8HbPJ7kevsNIaC19ox1FFA9F13EsgjS1dDxsISdjoLhNFWE1ixis0Y3XBmNZis5t I/5gtcOd0xnUw6ARTnW4uQ4/8MjvrvATU7x4Wdplsha229rfxoM5bzlDbP8DAF9hw4UV V3pcF+BIxd8lfVO+EVdC7rxp3SBBd6XqaQREKH8hw4lReMy833P8PCL/GdRY9Pu1hbee U4WjODGkFJbtn1WN3V+mPKeLSPevFLtVPr5JyOtQMJmZ5E+H5o5Q6NL1mG0x1x9tHnr8 UWjQ== X-Gm-Message-State: AGi0Puaoxkmk24jjovvNZLHBv6j9Yrfu3GlBSHySZf80rzJNHLAKYB+j GQmXjEJT9mfPFM333fDKoB4+Qg== X-Google-Smtp-Source: APiQypKUY5dArYVluRcs8mkYmPnZj4xAm7IXYKTjRk3l5Xn0/sMvRZ+xfUQyfi2oi6GID088I/+Oxw== X-Received: by 2002:ad4:46b4:: with SMTP id br20mr9111659qvb.62.1588784549465; Wed, 06 May 2020 10:02:29 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.95.18.252]) by smtp.gmail.com with ESMTPSA id w18sm1922556qtt.19.2020.05.06.10.02.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 10:02:28 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 737DE301FCF; Wed, 6 May 2020 13:02:26 -0400 (-04) Date: Wed, 6 May 2020 13:02:26 -0400 From: Alvaro Herrera To: Tom Lane Cc: Mithun Cy , PostgreSQL Hackers Subject: Re: DROP OWNED CASCADE vs Temp tables Message-ID: <20200506170226.GA15066@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3019.1586200129@sss.pgh.pa.us> 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-Apr-06, Tom Lane wrote: > Alvaro Herrera writes: > > On 2020-Jan-14, Alvaro Herrera wrote: > >> Hmm, it seems to be doing it differently. Maybe it should be acquiring > >> locks on all objects in that nested loop and verified them for > >> existence, so that when it calls performMultipleDeletions the objects > >> are already locked, as you say. > > > Yeah, this solves the reported bug. > > I looked this over and think it should be fine. There will be cases > where we get a deadlock error, but such risks existed anyway, since > we'd have acquired all the same locks later in the process. Thanks for looking again. I have pushed this to all branches, with these changes: > Hmmm ... there is an argument for doing ReleaseDeletionLock in the code > paths where you discover that the object's been deleted. Added this. This of course required also exporting ReleaseDeletionLock, which closes my concern about exporting only half of that API. > Also, if we're exporting these, it's worth expending a bit more > effort on their header comments. In particular AcquireDeletionLock > should describe its flags argument; perhaps along the lines of > "Accepts the same flags as performDeletion (though currently only > PERFORM_DELETION_CONCURRENTLY does anything)". Did this too. I also changed the comment to indicate that, since they're now exported APIs, they might grow the ability to lock shared objects in the future. In fact, we have some places where we're using LockSharedObject directly to lock objects to drop; it seems reasonable to think that we should augment AcquireDeletionLock to handle those objects and make those places use the new API. Lastly: right now, only performMultipleDeletions passes the flags down to AcquireDeletionLock -- there are a couple places that drop objects and call AcquireDeletionLock with flags=0. There's no bug AFAICS because those cannot be called while running concurrent object drop. But for correctness, those should pass flags too. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services