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.96) (envelope-from ) id 1wd0U7-003oia-1W for pgsql-bugs@arkaria.postgresql.org; Fri, 26 Jun 2026 06:56:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wd0U5-009ceY-2p for pgsql-bugs@arkaria.postgresql.org; Fri, 26 Jun 2026 06:56:17 +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.96) (envelope-from ) id 1wd0U5-009ceP-1u for pgsql-bugs@lists.postgresql.org; Fri, 26 Jun 2026 06:56:17 +0000 Received: from mail-ot1-x334.google.com ([2607:f8b0:4864:20::334]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wd0U3-00000000K1O-1v2S for pgsql-bugs@lists.postgresql.org; Fri, 26 Jun 2026 06:56:17 +0000 Received: by mail-ot1-x334.google.com with SMTP id 46e09a7af769-7e93f93ed01so442234a34.3 for ; Thu, 25 Jun 2026 23:56:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1782456973; cv=none; d=google.com; s=arc-20260327; b=NKn+dE5ZMbZkGHSv/EOR0g4bblZhaUKuFZqnpmQk/yDfhZGkozl7FpF3WJ7gguSzb+ NSXmoXXbW59xix8sE8f3nR3w0bxzcXGy2J6SJ2Ok1os01zGivwF+DI7nc2mwAMjwdnPl QaCPpxAcdItJ1ChG6u2gXKtii0HNiylmj8HsLXZv4Zy1J780RJ60lb4b66awy1Vn18aZ yz2cjzgQSyE39T4zjwTA0HtCQhat4GIBL4ak8Io9SCLj0wQBijR0yDBVvEflHELAXMu6 daT65MhDSSPwazXDUAJxWDkA200FTt+mjbpoQBIrEXEj08GtSI1qrQ1QRNsCktply9iX 6rtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=2cLe8QwAhnCuPCHLyNRJa0CQtN+cILUWrX2OUR1aOaw=; fh=ILNYx+wVD8xziQAF5D/ywZxZe+YD+BW7TP5mZnTd2vc=; b=MIkSimZWvHSK2rjfpJI9g+7vedOHipeMSinz5npPRPaYrUg4QFZ1VGV/bV1vTrbHVO Pp90hOYye5YyQA17RLsIjJm7RNPbDQFxR5XwHu/iu0Yj+qEEYe5aEMrjay4gTwS/wTrM Q4dDauNfqdcOlIdkLWjhPCaeJmy+zzzGuztnuqc7asyR/esUMkqhgL7QTeq2VsJcDoOT BJCVh2z7E+qNsdzMi/tr3SQfN4D+6RIMHZ6DjWIe58rXAWE2HXpwKsxH5b2k2IOs9qc6 Ev+B5XrXaiJwwIwjzSE3nBcK8iBKUJYmclwucG1pWzaUI+3gYzTm8qQIDxKTIdhUP9Vg 6ZAw==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782456973; x=1783061773; 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=2cLe8QwAhnCuPCHLyNRJa0CQtN+cILUWrX2OUR1aOaw=; b=ZFlXTHJei+uAfSeTJrnFSLchJimHsRVopLT0KgP5sO06tY3XMK04rBCbDOx1hukfGR 79ou6CIIGn5EvWUZ8UzY01eczN6odpfw5beMY0bGjwB7yA7gCkEw6YaHneK4S92lxgfo LUXA+tRSWxLzGJEgrxzguaOtrztW6COxl9A2YvdYP998XCTgdlEFfP+72wYPn7TrUuF9 YjQSGSUHgscp/u/EL9TAULR3v23QuYFGUXMiQWJurLaToax7jNrKd1vlTRoXHJ+kkF0r joYPmInpE+glQn9rsjBQ5V+9E64H69N21Q3M7rAY8+gUKmRoLWyFNFoP5W/maEltaJ7u dcag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782456973; x=1783061773; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=2cLe8QwAhnCuPCHLyNRJa0CQtN+cILUWrX2OUR1aOaw=; b=P2Ot3c7QzIwnlhPkUApFD8CQl+qpfpEp+GBQNGp/yLgJM0oVR0X80jLQKiXl3L2Z7e XdnjZWyQ2DiSbfOymKkA4hgWa4n9s3VMzDokNZ/BI6VHoAyvWGAH9fgiW+Eq9hznJv00 +c1Ke/abAoOkPBUcj43DmDeE228Zb5DNm/sANzHfxqTsmS732boQjOYALagF7zAoNcPG hPeBlHBgm1rI/RPprCI8zvAbEzVagG3BNv+Q35+R+1HOslgnpiuReojZmsKp5ERdE8Tw ETN59xuSoKFg2xJQ/jVgcHHrg7vOpEiLMPf8DN8S3XH3rBvcNMdG5XMiBRP5ipIFayAT 8kFQ== X-Forwarded-Encrypted: i=1; AFNElJ8a35zhChklNciCT+Me2n9jkWHssoK+jJJTbiNc2dYtp8FQbYL1j25LTsS6zyQOuyatUY7NJAPgkDcc@lists.postgresql.org X-Gm-Message-State: AOJu0Yxg1Eqt/sVSY5SiePV5unmQRF7vsIiJHt0FehZEoRw2cEuzAl6i nnxPITvSF3gRYRtr6MzOJHO7T9toO7G7teaXInMJ9HLWmlZBiaifqrQcj/ZowgRJz5P2slkZCAn lMIY2NoRUneFtKGEeWhEJn+GqX+srvcM= X-Gm-Gg: AfdE7ckNdmS9jArRtPUKhQTVwbr3EomGbEAtv4fePcZ6sK+Y3N8odhzwIrmDMbq6Fub G1cNQNOMlzfk9dDccyyidh1t5LzpVIRXyO/QtON6aDlh3ct//YXgsj3xjduXZ4JVUot7izEWmsU bnupnnWvhBK2ODR7T8LDkMTU6Fac9u/6ZD+kXfdroKXpMZKzgxC+BTau4xzpjoFzTvqTBHfXVRv APaKrF1MnD19rY1XZrI/6noUAo2qYp5+DVbbPpwlUzkBqEBq9n/j6UbJmbvZuI0awGtupjtIQeS SDpsvsMMMvEJQjcyNSpMQ1PQ4wgHzhw1CdIM7Qc8J4/+qQbhy7ewL+F0X+fBXytOhbrINue0z0P TzQV5FiekSIG7RllG X-Received: by 2002:a05:6808:1524:b0:489:6bfc:9b52 with SMTP id 5614622812f47-4921880bf44mr4819952b6e.36.1782456973169; Thu, 25 Jun 2026 23:56:13 -0700 (PDT) MIME-Version: 1.0 References: <19483-80de42dc4e62cfd6@postgresql.org> <104812.1780847519@sss.pgh.pa.us> <5184088806e70ed5db7e83bd6540a016b3802c1d.camel@cybertec.at> <0d7531c192859057c6aad54c89a8d453376bd00c.camel@cybertec.at> <592839.1782153054@sss.pgh.pa.us> In-Reply-To: From: =?UTF-8?Q?H=C3=BCseyin_Demir?= Date: Fri, 26 Jun 2026 08:56:00 +0200 X-Gm-Features: AVVi8CfqmDcBIjlUVi5WOobWpg3CsB0ImB5NNZDoKtuz6V-9YemqrfllxijRbr0 Message-ID: Subject: Re: BUG #19483: pg_upgrade fails with orphan records in pg_init_priv catalog table To: Laurenz Albe Cc: Tom Lane , Greg Sabino Mullane , pgsql-bugs@lists.postgresql.org 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 > > This v6 patch adds a SAFE_INITPRIVS macro that filters aclitem[] > > arrays server-side by checking that each entry's grantor and grantee > > OID still exists in pg_roles. It is applied in exactly two queries: > > > > 1. getAdditionalACLs() -- the one-time fetch of pg_init_privs at startu= p > > 2. dumpTable() column ACL prepared statement -- per-table column initpr= ivs > > No, that's not good. If you are running the complicated subquery for > every table dumped, you are re-introducing the performance regression > from the v4 patch that Tom justly complained about. The correlated subquery in getAdditionalACLs adds overhead proportional to pg_init_privs row count =C3=97 aclitems per row, with each check being an indexed OID lookup. For a database with 5,000 pg_init_privs rows this is probably a few extra milliseconds. I added performance test results with v6. I think it's a sustainable operation but If I'm missing sth. let me know. > On the other hand, I agree with you that Tom's idea to make this fix > depend on a minor update of the source server that fixes the string > representation of aclitems is not so great. Few people undergo the > hassle of applying the latest minor update to a server they are about > to update (and I am not even speaking about the users who keep running > on the 14.3 they went into production with). Yes, the problem that > the present patch is trying to address is a rare one, and we should > keep the maintenance and performance burden incurred moderate. > But what good is a fix that won't work for a good percentage of the > affected cases, even if they are few? > > Here is my latest idea (hold your noses): > Instead of having pg_dump query "FROM pg_catalog.pg_init_privs pip", > how about writing "(FROM (VALUES (...), (...), ...) AS pip", where the > VALUES clause is composed from a query against pg_init_privs run once > at the beginning of pg_dump that excludes the bad entries? > Critizism I forsee is that a) this is ugly and b) very long VALUES > statements might also constitute a performance regression. > However, I have yet to see an extension that produces a hundred > initial privilege entries. I'm not against this approach but the tradeoff is the same with v6 I suppose. Since the overhead of processing the full VALUES clause on every EXECUTE is unnecessary. v6 goes directly to pg_init_privs indexed by objoid =3D $1. But definitely we can prepare a new patch to cover these expectations. With that in mind, I would like to propose splitting the work into two separate patches: 1. pg_dump fix (backpatch to 14): the v6 SQL OID-level filter. Works on any server >=3D 9.6 without requiring a source-side update. Fixes the known breakage for users upgrading from pre-17 clusters that accumulated dangling entries via DROP ROLE. 2. putid() fix (HEAD only): improve aclitemout so that a dangling OID is rendered in a form that is unambiguously distinct from a valid role name. This is the right long-term fix for the text representation and would benefit any future tool that processes aclitem output. It is independent of the pg_dump fix and does not need to be backpatched for patch 1 to be correct. New dangling entries will not live on modern servers. However, users upgrading from pre-17 clusters may have years of accumulated dangling entries that pg_upgrade will carry forward silently. The pg_dump fix is a one-time for that migration window. Does this split make sense to the reviewers? If so, I will prepare v7 of the pg_dump patch (incorporating any further feedback on v6) and a separate patch for the putid() fix in HEAD. Regards, Demir.