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 1s91te-00Gsdl-P4 for pgsql-hackers@arkaria.postgresql.org; Mon, 20 May 2024 12:13:44 +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 1s91te-001PSi-D6 for pgsql-hackers@arkaria.postgresql.org; Mon, 20 May 2024 12:13:42 +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 1s91te-001PSa-3T for pgsql-hackers@lists.postgresql.org; Mon, 20 May 2024 12:13:42 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s91ta-001BhP-PU for pgsql-hackers@postgresql.org; Mon, 20 May 2024 12:13:41 +0000 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1edf506b216so68808545ad.2 for ; Mon, 20 May 2024 05:13:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716207218; x=1716812018; darn=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=05R+jXei/58fQzhkNuGiaPMihDHHsVaJqxY9PTgnBCo=; b=g4CvdWKjeT4WRFjlQZiruO42Ah06vUGGq9fZUGHlJWfmNF8GmVlXnXwNuEbAxWfwgM CGB4C9Gz/DPhB6g0MDkRXkPh+j5K9rItaCNyr3zpchVDhLCZ7aBfYizhMD7UiKMRbHD1 Vj42MKJETBWFQB9880Kbnx/74fCu3XrgePQcgMJwY1UeaeAKB7mfiz2sPqilDyJQ5Zwo cjMGPSnYQkWV1g+gsrC4T4TctXwgopBzo+MW+AUNndcKjwiDgJkUna6wlqoVf9c2JZYq aVZjc4xMICLD3ZTTpgQWYhrSl+9OxS3JKGnSLFFDjnkVEBwp8OjFmFLf8/bKFRnyQRAw AMYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716207218; x=1716812018; 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=05R+jXei/58fQzhkNuGiaPMihDHHsVaJqxY9PTgnBCo=; b=WNob7IEw7V70Y1ofZv69khtBEwNOusyRnPt9Rd/Plw7T0wGBuLu50f8LsIw/GTT5/r mBoRpyKdhvzla4NhCPiJ60TkZWsaWrEj/lbAH+yKrQKw7WzlE/LhqParYp9hUfvLO9AP d/kNosi32NLi3nPK6CxAV4DG405/IeMq5PmI898ElUXvtWyJH7qSktx4fzYDe2ZUDJcX xuCBJWRDLl8SHCoc+Mg6iFxrQxuaoZ5dPNJwU82UvisHUeAG0lIey9l5m4lRkL1fK+Bg FEZ2SjfqQxq+TbqkqtVkXIjy98X53ObtDK1KMXDr1hjnFezG2W7driWXP+XB4fE88y42 eo7g== X-Forwarded-Encrypted: i=1; AJvYcCVAigd0UsTeZEj+6EEGXcmSJzwau2GXBNRIRVwWmgHnE65ecth23uhcvJ/3YddAnKIt5xSbbjSaoBZNBl4l3NTzft8haRuTwPWys7pn X-Gm-Message-State: AOJu0YwFNm0DY+7WvRode4Apb7m1OyjTkDLl7ZcBOwiuFyjqkdGRmWsp nZZFP1vT6aTYm+Z70v/Ii7oHdGUj1WRjMTVQyng0DD9DkdUZDsuMLZHOrTO9p2d6yOZ2UEG3IHa vWBuiDbcof9uttSVeL18yDeIyhr4= X-Google-Smtp-Source: AGHT+IEteWimPf2cMLNoEf/6MLb/a+adtdCPV0nMnH6gmwNFxT8N2b3/vU919GGdnLUPLAq8RWwomLZLymgw1vaWSVM= X-Received: by 2002:a17:90a:f495:b0:2b6:22f0:7696 with SMTP id 98e67ed59e1d1-2b6ccb7e749mr25602470a91.32.1716207217613; Mon, 20 May 2024 05:13:37 -0700 (PDT) MIME-Version: 1.0 References: <20221221101846.7zsi7lscnm5ediik@alvherre.pgsql> <1350682.1671635927@sss.pgh.pa.us> <4191508.1674157166@sss.pgh.pa.us> In-Reply-To: From: Amit Langote Date: Mon, 20 May 2024 21:13:21 +0900 Message-ID: Subject: Re: generic plans and "initial" pruning To: David Rowley Cc: Tom Lane , Alvaro Herrera , Robert Haas , Jacob Champion , PostgreSQL-development 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 Sun, May 19, 2024 at 9:39=E2=80=AFAM David Rowley = wrote: > For #1, the locks taken for SELECT queries are less likely to conflict > with other locks obtained by PostgreSQL, but at least at the moment if > someone is getting deadlocks with a DDL type operation, they can > change their query or DDL script so that locks are taken in the same > order. If we allowed executor startup to do this then if someone > comes complaining that PG18 deadlocks when PG17 didn't we'd just have > to tell them to live with it. There's a comment at the bottom of > find_inheritance_children_extended() just above the qsort() which > explains about the deadlocking issue. Thought to chime in on this. A deadlock may occur with the execution-time locking proposed in the patch if the DDL script makes assumptions about how a cached plan's execution determines the locking order for children of multiple parent relations. Specifically, the deadlock can happen if the script tries to lock the child relations directly, instead of locking them through their respective parent relations. The patch doesn't change the order of locking of relations mentioned in the query, because that's defined in AcquirePlannerLocks(). -- Thanks, Amit Langote