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 1wWnqf-002rha-1z for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Jun 2026 04:13:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wWnqe-004nyn-1D for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Jun 2026 04:13:56 +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.96) (envelope-from ) id 1wWnqd-004nyb-35 for pgsql-hackers@lists.postgresql.org; Tue, 09 Jun 2026 04:13:56 +0000 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wWnqb-00000001n3H-3nej for pgsql-hackers@lists.postgresql.org; Tue, 09 Jun 2026 04:13:54 +0000 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-c85c531d4a9so1999382a12.2 for ; Mon, 08 Jun 2026 21:13:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1780978432; cv=none; d=google.com; s=arc-20240605; b=c3bsV2JrcKZcAt1gUqM/SZLrIHJWoEdUzvhSMZMOC10VUf8zMmxrj1cX2RU/Ko5hRb y9j+udjHgEbcWpFd456IWRaHIwug5tY0DZyftWqxm6QpjTq81sGiqXGCb6wkWgwL6aIy FAcaC8a1r33yZ3AIn9Rici7GPk8FdNY418X6QkCEWQiqMMnAPcY0Sz1sqeeXObvTh0Ws A/hJkMnWiSxm7G2lFziLwHu8R3oB//wBgPSBeH0sMAWSbS78tEaeBQViuIONd3Mq+6mc i/yKKz6dPuuvKYApABmHPG4cLGL4dmYacjdxwAbyg2NViftVLl3sA9ATjd23UHGpwTDH Wf+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=cOnP3d9cS1Nd0SytKTlFQK4YlnEsaBJD8edQZAtzouM=; fh=zBFxNdEsTGef2U4AITWfYkAQZ4WPlnoICcEEyKI6bik=; b=EYM3Cv62GpzdXNFJYgQO0SgVTbLfFiUZh7M9jRqVJLjCSzmVFan2SQ0/Kj09eq4G7v AELwgA2x6hw605w8llJCjJTsNFxBefk4q2bvvtG6sewLpqfN7mD96VnXQ84huhPeC/u2 EH6wh5F80m5tB6dnZwz5XvLZm1vJvkHeOmKZOgHyQtNfqW/3StGayJhx6bswGxXure/X D0EzbTfGFvj/GDe2nVbI9VoQHVwHxlM6YyBzIqY4qW0g5nEfMcHaBuGcwLu8fih1liMb VW/iIzjpK7koMYe2Vwul5Q/xdH/8yv1fFh+SEnDgGL2s23RgELsSYJULtYz21pZGyKHS b7vw==; 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=1780978432; x=1781583232; 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=cOnP3d9cS1Nd0SytKTlFQK4YlnEsaBJD8edQZAtzouM=; b=dVEEankyTsn3DxbLyoJoSJBlJB/gA9ivimgSzn/8pe0hJ7Q0ITwi4nMQ82QipPupHI UNnaYduqd3qK5LtwQ7JjJv2K2596BV/M5HkW3eZPnJch6TXWQ/uxWXvjq5NMWevHYYeH vCpY9/YFrEJBUCkmh8uUqbyz4wKh6PP8BB5A8zI2Pweb/yJgaFmj2cA0cRwJRdpFt4A0 E77eQ4awC7vWJ8PWIB5MoEKjBbDHK0UXk5xDErHkflar4mMgC+nXmezInMuWD9XV5epd N/e20xFpSGc+5BCDbqTrzkQX6exltJ1B4j2eU2SudhS7blcy9TgRNwN/Df2aSs87AlMY J6/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780978432; x=1781583232; 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=cOnP3d9cS1Nd0SytKTlFQK4YlnEsaBJD8edQZAtzouM=; b=V7IRRmeUeK6bx1BQggVwMhrldHNNIv6Z4Weqn4s7WNxMUMuL5hxvfuzSWwtZ6Gkp7Y oarAMngoY9fKn3JN8u5+wYXhypn1EBCWbP9TU51Z8U/C3ucty8hIHS2LzOh+C9p5xCvw 4tJbfsMtNxjR+Tbqz31gbftIeV81igoGnzICVJk/wNQlJfh1py+my2Hzk1jQP7857wst 3niFoN0+60Uddf6MWlruv0bDYrTM5NN8uBnGQg47AwaVCrDU6+tT3o9C/URhEXLg4xqj OlXCdfQdosOFcJHmSZpanlDuciqq4waB4qWvdwQA6BsLX57zmsKvRTU37HTblXJrJEtJ USkg== X-Forwarded-Encrypted: i=1; AFNElJ9d+osgK52ZtuKdA5evK7RLfenXc0NwYQNej1jpdAluslR3XNl1LrEp17P9mEU907oAFuenWKFdPeKm3l6U@lists.postgresql.org X-Gm-Message-State: AOJu0Yz/dzju+qQS//+nq+LN3poM8RPtjEo6h32oNIlr+VZAGZcvY2E9 uYVIh07H/ZbBk+UdmtlFVab+MfX2FJnvFI1BPxqG3EmfJS13zMz5JXN+kJ08m5euLWXzFUqaISy WzFNej+9vqH8S34NgBNfhjjkC2OyO7o0= X-Gm-Gg: Acq92OEC76w/CKPtEEbVxqZB6Nu1dq1t7HtDXonrgectKcodFASpdeMdmvgD2TYxQpx 3RpwEU2AcRN+mJSP9OK+7B5y6D1RJ+BT2Q3XCZSqxf8/qi2Gt+hUTPfLZcRS6bbGgOJqI7Mn+QM ru7PLIKZ3RIrsk+Y9Bb5YWFl4gRcaenu/AklcAMu3z/BIZtUhkoYR/nAMgJ+T/ALzJQ51DMLvYg rwmlvnHOSfTcuKQ+0NSgnzKsTqBcQ//gD92qtIukskMrBcePnGc4EReSrp48QUQw7yzgiLwawmI s/h9bDZvjg7E9mN+vPQKRaOwwRszexCIz6PxVOSGiE310XUw1n2PZeJKtbreCg== X-Received: by 2002:a05:6a00:278b:b0:83f:2568:d45f with SMTP id d2e1a72fcca58-842b0f4d10dmr18411628b3a.23.1780978432169; Mon, 08 Jun 2026 21:13:52 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Tue, 9 Jun 2026 09:43:40 +0530 X-Gm-Features: AVVi8CcRbHOrwkYMFNdRwTk-y55ICUekUEl5PWnvc2M1zw-1oSn_3LQ86XM14zo Message-ID: Subject: Re: [PATCH] Preserve replication origin OIDs in pg_upgrade To: Ajin Cherian Cc: Shlok Kyal , Zsolt Parragi , vignesh C , "Hayato Kuroda (Fujitsu)" , PostgreSQL Hackers , shveta malik 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 Thu, May 28, 2026 at 8:18=E2=80=AFAM Ajin Cherian wr= ote: > > > >> 3) >> >> + >> + /* Dump replication origins */ >> + if (server_version >=3D 170000 && binary_upgrade && archDumpFormat =3D= =3D archNull) >> + dumpReplicationOrigins(conn); >> >> why the check is for PG17 specifically? >> > > In PG17, we started migrating pg_subscription_rel and the remote LSN duri= ng upgrades; prior to that, these were not migrated. Given that change, it = also makes sense to migrate replication origins from them. Otherwise, when = upgrading from PG17 to a later version, you could end up with a subscriptio= n where pg_subscription_rel and the remote LSN are migrated, but the corres= ponding replication origin is not created. > Okay, please add a comment in code for this. Please find a few comments on v007: 1) + node =3D (ReplOriginId) node_oid; + originname =3D text_to_cstring(PG_GETARG_TEXT_PP(1)); + + if (strlen(originname) > MAX_RONAME_LEN) + ereport(ERROR, + (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), + errmsg("replication origin name is too long"), + errdetail("Replication origin names must be no longer than %d bytes.", + MAX_RONAME_LEN))); + + roname_d =3D CStringGetTextDatum(originname); CStringGetTextDatum is: #define CStringGetTextDatum(s) PointerGetDatum(cstring_to_text(s)) --------- We are first converting text to C-string , then Cstring to text and then getting Datum. Double allocation and double conversion. Can we please try this instead and verify if it works: text *origin_text =3D PG_GETARG_TEXT_PP(1); originname =3D text_to_cstring(origin_text); roname_d =3D PointerGetDatum(origin_text); 2) +check_new_cluster_replication_origins(void) +{ + PGconn *conn; + PGresult *res; + int norigins; + + /* Quick return if there are no replication origins to migrate. */ + if (old_cluster.nrepl_origins =3D=3D 0) + return; Don't we need a version check simialr to what we have introduced in pg_dumpall for origins? (Similar to check_new_cluster_replication_slots as well) 3) Since we have introduced check_new_cluster_replication_origins, do we even need below checks in binary_upgrade_create_replication_origin()? In which conditions will they be hit? + /* Check for OID collision */ + .... + if (collides) + ereport(ERROR, + (errcode(ERRCODE_DUPLICATE_OBJECT), + errmsg("replication origin with ID %u already exists", node_oid))); + + /* Check for name collision */ + .... + if (collides) + ereport(ERROR, + (errcode(ERRCODE_DUPLICATE_OBJECT), + errmsg("replication origin \"%s\" already exists", + originname))); 4) Now since check_new_cluster_subscription_configuration() is purely about checking max-origin GUC configuration, I think the name is misleading. IMO, we should merge it to check_new_cluster_replication_origins(). See how check_new_cluster_replication_slots() does it: checking both new-cluster's count and the max-configuration for slots. thanks Shveta