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 1sJFAH-003ew3-Hr for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Jun 2024 16:25:05 +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 1sJFAF-001SbZ-8U for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Jun 2024 16:25:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sJFAE-001SbQ-VQ for pgsql-hackers@lists.postgresql.org; Mon, 17 Jun 2024 16:25:03 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sJFAD-0029Cw-7W for pgsql-hackers@lists.postgresql.org; Mon, 17 Jun 2024 16:25:03 +0000 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a6f0c3d0792so524790166b.3 for ; Mon, 17 Jun 2024 09:25:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718641498; x=1719246298; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=8wM9DPfAc0hBV8ZxFGIdl5P8tA83UJjlvaabfvTJGBI=; b=jtpD8G/6SNkMFAn5x6s2yOUtQq351KSpJJbVGFr2SxjvUbErl4dpNISWdctSLtiD8U K++bYUiKv8sWht/ywXLsvSaFzUejqYvT8I1sAzB021HahzlJta9Y6S72j+R7vwzbI60c 1bsD2jZfg84hIX5KIEBCDws4/OWAGBJjmO+ULnSW8B1b9xYhHbdfb76ZGtgw16fP0dnQ Ioos+4i+wfdo+SM90GDJzWP4suV8kPUtBy5HX4TqtaT0yo/rmO+f94HNZsaXO1CqDc7a OIo5nd40fhtVuzaLLTqpBa+Yc85GPdwdWxJBYA2fuhkwvgFb870/jjOo0LSYhqacvuDO BEZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718641498; x=1719246298; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8wM9DPfAc0hBV8ZxFGIdl5P8tA83UJjlvaabfvTJGBI=; b=qjFZkP6M6ZL7yisnlwDWhmMQsueDzaQCHqGp0gmOqATR5YGYaPFcvr9FKFtrt0ZRyj 8MSUoKXUNAn9NJoE01qu0bwOcDpbdADniwllD6bGefQdP+fKljeb4oMt2zOX6iKyybqx 2ptKodw5wGt3qfdZ24Jyj50VFg4NjhBVhstmDmF1ktegm39nzjcrbnz8/9j3+Q1BTZPf 8V9XbPwjr9+iEZ957xS67oGcASB4auVQObxZiujZj5WZQ0XjMI/MWdw8ziEuEb51VZCo 9QhPHTi/7becGgjmgdjkThMwcuKn7b/oFsxOiEyXylTWTXUqCZQXw6YxG0mP+trfgll8 j5KQ== X-Forwarded-Encrypted: i=1; AJvYcCXa7WGXhRZqCOWgj1jOijW38QPY0blHZW/3Nq9YRQ0S54gCMazIGXnE/JeOIbN59y7lx0u7JdoQJxo8MCPMuzRr7SkVqtgIzMND8CXeeyq1+NJ1 X-Gm-Message-State: AOJu0YzSt5JhP9f5gELQ6KpyJ0Rom6+dyl7MihABUFJMiq9id1ZEBEhH F+GJU80cl/FWrvBGCYfs1+gyE4cGO1Pevh0qqqrzxHCCBy0NBLp4OEWSw2VspQGA50e7o3+OTdT ZFOJwOM4sWR7//fW+C6Gop86NnI7MyyTk X-Google-Smtp-Source: AGHT+IGcW9Aq3bEqE5V7jpQC0M9IVLX/E6ts6Lxh8byrRNsxZdbP5JWqXSsFehAPSR0oJVBQSGvo1cUefJ9H8HuR8Tc= X-Received: by 2002:a17:906:4341:b0:a6e:d339:c095 with SMTP id a640c23a62f3a-a6f60dc7feemr661766966b.47.1718641498309; Mon, 17 Jun 2024 09:24:58 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Robert Haas Date: Mon, 17 Jun 2024 12:24:46 -0400 Message-ID: Subject: Re: Avoid orphaned objects dependencies, take 3 To: Bertrand Drouvot Cc: Michael Paquier , Alexander Lakhin , pgsql-hackers@lists.postgresql.org, Tom Lane Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Jun 14, 2024 at 3:54=E2=80=AFAM 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? 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 =3D=3D RelationRelationId || object->classId =3D=3D AuthMemRelationId) + return; "It looks like X cannot happen" is not confidence-inspiring. 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 =3D=3D RelationRelationId. 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. 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. --=20 Robert Haas EDB: http://www.enterprisedb.com