Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sJGbS-003ykl-6P for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Jun 2024 17:57:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sJGbQ-002HND-1h for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Jun 2024 17:57:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sJGbP-002HLP-Nj for pgsql-hackers@lists.postgresql.org; Mon, 17 Jun 2024 17:57:12 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sJGbN-001mbq-SA for pgsql-hackers@lists.postgresql.org; Mon, 17 Jun 2024 17:57:11 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-421a1b834acso38582185e9.3 for ; Mon, 17 Jun 2024 10:57:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718647027; x=1719251827; darn=lists.postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=8oDzQASN9N9TiOPDZxuIvDdnLS5TEVfV0+Xkc3O5Rk0=; b=Tm/khopHq1ry8qjLrMg8ByQm7KqFxUVlqGkwdWRfMw4S5RGD/UoJDq2YzNhXlPSWDk 5oKXnQdE9xiiWwAvl30Ixy9XA9EpAL3AFEwCTtstO4a4llH3E38gnQkbQEQ6fdU6qRfi hUCBE4S4O37nX5tMuc/cNLkdXwh6Beam1TzYyyS/LHsWd6lNZuwa2GehsL5gjR74Yhbc Bnf3Vk9KUdNK3Sz9rKuE2nMjykF0AdYkweUXslDIt9R/8mxmjHHHB8d+jYSa++SClru0 OVAGUyeLVq7kUXS+wnrmDl9wacQTS68vX/zn8JvGxY4UWmTE9E1/uZTnYGQ0yVFQ6tr3 zX8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718647027; x=1719251827; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8oDzQASN9N9TiOPDZxuIvDdnLS5TEVfV0+Xkc3O5Rk0=; b=gMkghHVMWVC3dqo75sxoyfuWDUv+SHwyGhr0VqQztwpxQ+341mVZ+hOL+kCF47Ytbc E4KVE6NAfmm+ZLtIwluLYNqU5N8RnDgQaop2glU6MmV21CI5Bme9RbGVr8G0TAsQe1pX 7AzFuSbaj2Qzs1stVLObEDNzDeiGsnkVTRxFvDGlly+/sbIwSbBdBw/jA7rqL9wqyHGx 1KPmWAyZqK63t3XvP7zb6zndQpxs45b1fYCex9qZrEWxaxPYC+HBRkknRB4X/lJnlAYd MV5mKkbJYiHdZkPVaVR56izjvxXaAlKu1yYE0zZP8JZynk1HWVpkUbjA2Wxc7rP1usHy fJFA== X-Forwarded-Encrypted: i=1; AJvYcCXowGPthCF8AE1Aql33eS2+XyWT3lDmhoob5W5PTlUSgkiTEAFgngaX05T7ltfGzp0S6ioclLRtwgerCY+S1ISIeG/D+pwahepZt4GtodsFZ18u X-Gm-Message-State: AOJu0YyZY4rYfxvV9N/XsOITOv776HAi3oUwHWsl7M9EL/f6ykz7V/sz IHA4OYaCF9IXjwfVDVQNNVgFqAp5ek4hed5/GSdIbDQxN7Nzl5t/ X-Google-Smtp-Source: AGHT+IHsK1yKlPwMt/e+sXrU+F8PJYqyx1Kak/WVERFu+9UJh1ckAzaVJUq9HZskLjjawcS0twuAPw== X-Received: by 2002:a05:600c:4e52:b0:421:7296:ba3f with SMTP id 5b1f17b1804b1-423048309d5mr91345595e9.22.1718647026742; Mon, 17 Jun 2024 10:57:06 -0700 (PDT) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-236-134-5.eu-west-3.compute.amazonaws.com. [15.236.134.5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-423047e28b7sm139992505e9.44.2024.06.17.10.57.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jun 2024 10:57:06 -0700 (PDT) Date: Mon, 17 Jun 2024 17:57:05 +0000 From: Bertrand Drouvot To: Robert Haas Cc: Michael Paquier , Alexander Lakhin , pgsql-hackers@lists.postgresql.org, Tom Lane Subject: Re: Avoid orphaned objects dependencies, take 3 Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Mon, Jun 17, 2024 at 12:24:46PM -0400, Robert Haas wrote: > On Fri, Jun 14, 2024 at 3:54 AM Bertrand Drouvot > wrote: > > > Ah, right. So, I was assuming that, with either this version of your > > > patch or the earlier version, we'd end up locking the constraint > > > itself. Was I wrong about that? > > > > The child contraint itself is not locked when going through > > ConstraintSetParentConstraint(). > > > > While at it, let's look at a full example and focus on your concern. > > I'm not at the point of having a concern yet, honestly. I'm trying to > understand the design ideas. The commit message just says that we take > a conflicting lock, but it doesn't mention which object types that > principle does or doesn't apply to. I think the idea of skipping it > for cases where it's redundant with the relation lock could be the > right idea, but if that's what we're doing, don't we need to explain > the principle somewhere? And shouldn't we also apply it across all > object types that have the same property? Yeah, I still need to deeply study this area and document it. > Along the same lines: > > + /* > + * Those don't rely on LockDatabaseObject() when being dropped (see > + * AcquireDeletionLock()). Also it looks like they can not produce > + * orphaned dependent objects when being dropped. > + */ > + if (object->classId == RelationRelationId || object->classId == > AuthMemRelationId) > + return; > > "It looks like X cannot happen" is not confidence-inspiring. Yeah, it is not. It is just a "feeling" that I need to work on to remove any ambiguity and/or adjust the code as needed. > At the > very least, a better comment is needed here. But also, that relation > has no exception for AuthMemRelationId, only for RelationRelationId. > And also, the exception for RelationRelationId doesn't imply that we > don't need a conflicting lock here: the special case for > RelationRelationId in AcquireDeletionLock() is necessary because the > lock tag format is different for relations than for other database > objects, not because we don't need a lock at all. If the handling here > were really symmetric with what AcquireDeletionLock(), the coding > would be to call either LockRelationOid() or LockDatabaseObject() > depending on whether classid == RelationRelationId. Agree. > Now, that isn't > actually necessary, because we already have relation-locking calls > elsewhere, but my point is that the rationale this commit gives for > WHY it isn't necessary seems to me to be wrong in multiple ways. Agree. I'm not done with that part yet (should have made it more clear). > So to try to sum up here: I'm not sure I agree with this design. But I > also feel like the design is not as clear and consistently implemented > as it could be. So even if I just ignored the question of whether it's > the right design, it feels like we're a ways from having something > potentially committable here, because of issues like the ones I > mentioned in the last paragraph. > Agree. I'll now move on with the "XXX Do we need a lock for RelationRelationId?" comments that I put in v10 (see [1]) and study all the cases around them. Once done, I think that it will easier to 1.remove ambiguity, 2.document and 3.do the "right" thing regarding the RelationRelationId object class. [1]: https://www.postgresql.org/message-id/ZnAVEBhlGvpDDVOD%40ip-10-97-1-34.eu-west-3.compute.internal Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com