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 1rkR5v-00Cjda-9P for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Mar 2024 16:04:43 +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 1rkR5t-007CTJ-8e for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Mar 2024 16:04:41 +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 1rkR5s-007CSC-RJ for pgsql-hackers@lists.postgresql.org; Wed, 13 Mar 2024 16:04:41 +0000 Received: from mail-yb1-xb2c.google.com ([2607:f8b0:4864:20::b2c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rkR5p-004JTx-DW for pgsql-hackers@postgresql.org; Wed, 13 Mar 2024 16:04:40 +0000 Received: by mail-yb1-xb2c.google.com with SMTP id 3f1490d57ef6-dd10ebcd702so5844271276.2 for ; Wed, 13 Mar 2024 09:04:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710345878; x=1710950678; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=cmaZKjsi6EDFpvQHCPGQiZogliSNwu0No/yxHr7hYTc=; b=QJSfwXqTTsYQsFrvDrecD6BGbMg4odniGB9gBOsfC8hgzxZ6rbovFWXWoWt/VfSZsR uqp1iJgfrt2aVhcNh+Un30xdX9rVbRHQLRAFaNND0S3o3JtrqqU5jkwN71k7/fEWBKPP ExFRMn1vodgeRUiIyX4h4DGZ4yvJBOW5KQu+J0j2txI2eUKAukMFfQ9Zqq9tvGtQEwy+ 6wB8hRr5UqrivuWRL9CSWlKbOwNUL2DCQcOafS5GfSuJbAwQ8lIgRz0ZRPHA/CaSseq/ Ei6BXigKvZ0g04KNrPS07AyxwQNyg6zO+CgAGRj2B2fg6D+jbX3tGwnGtrMwjEmHxVH6 yNpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710345878; x=1710950678; h=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=cmaZKjsi6EDFpvQHCPGQiZogliSNwu0No/yxHr7hYTc=; b=R5ZOQQf1d7ODoZzb3AWocrD3wTBybDbEooU6CvFhbTUjGfl8sk428EvwlbPaBeExxe b41rYrhRaK8nTJlITOkvcmJf1hAmyaXtNFHIZZb7D575cKl9ZWEV7tMECm2Uf703OGhn NwjcSrIjexrZHDL+zeHwEAJAjDxW4cWpb6v4EKnN/QqnLeSD7C9Ip9JoOpri1wbflggJ LYZ9MX5+SBZwxXJtbDG0fDXnumbf5l5FF3Lzvcppy0nuRI8BzufLjYmcBcFq4GQfqyR7 WqOQYv4DcOt/adqhVG/vIBJ3tYug5E/Bwl3l7k4OWxxAXzzXicGQXw2WUaeZLDG61Twh pcPA== X-Forwarded-Encrypted: i=1; AJvYcCXcHyaJUTr1l6c63y/yGj9M5Py8nreVD09ds/OKKnQJnDL4SIEIwMBI8CJf5Al77tGCJd3KppBb6E9cKTkcvp3VgIMUHg1CYc9CtCUH X-Gm-Message-State: AOJu0YzKlUIqBWu1+rJlRmNvJzFo+WP5KCtTmyv18BZ+hIy2kO1ROCd0 HvATv4WFqzt13jT/KBn9N7aJ+G88fPTFwMHeuLYf6SQj/sRe6yHF6Er17J2otlGrSCostiG/ki7 pEEiO3IWZGpz9kCX5JJ2Vch/JtfI= X-Google-Smtp-Source: AGHT+IGLRLOJOYrALsYeVnjmchjT84pomop7NywO6XLB30hGVfPjeKYO8IYbCorK5I3Nj45cOX7FEd9fI3FJ0lfaaJM= X-Received: by 2002:a05:6902:240c:b0:dc6:4b66:2636 with SMTP id dr12-20020a056902240c00b00dc64b662636mr3850902ybb.19.1710345877522; Wed, 13 Mar 2024 09:04:37 -0700 (PDT) MIME-Version: 1.0 References: <20240221.120424.79274783106518358.horikyota.ntt@gmail.com> In-Reply-To: From: vignesh C Date: Wed, 13 Mar 2024 21:34:20 +0530 Message-ID: Subject: Re: Have pg_basebackup write "dbname" in "primary_conninfo"? To: Amit Kapila Cc: "Hayato Kuroda (Fujitsu)" , "robertmhaas@gmail.com" , "barwick@gmail.com" , "pgsql-hackers@postgresql.org" , Kyotaro Horiguchi Content-Type: multipart/mixed; boundary="00000000000079ad3806138cee9f" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000079ad3806138cee9f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 13 Mar 2024 at 16:58, Amit Kapila wrote: > > On Tue, Mar 12, 2024 at 5:13=E2=80=AFPM vignesh C w= rote: > > > > On Mon, 11 Mar 2024 at 17:16, Amit Kapila wro= te: > > > > > > On Tue, Feb 27, 2024 at 2:07=E2=80=AFPM Hayato Kuroda (Fujitsu) > > > wrote: > > > > > > > > > PSA the patch for implementing it. It is basically same as Ian's = one. > > > > > However, this patch still cannot satisfy the condition 3). > > > > > > > > > > `pg_basebackup -D data_N2 -d "user=3Dpostgres" -R` > > > > > -> dbname would not be appeared in primary_conninfo. > > > > > > > > > > This is because `if (connection_string)` case in GetConnection() = explicy override > > > > > a dbname to "replication". I've tried to add a dummy entry {"dbna= me", NULL} pair > > > > > before the overriding, but it is no-op. Because The replacement o= f the dbname in > > > > > pqConnectOptions2() would be done only for the valid (=3Dlastly s= pecified) > > > > > connection options. > > > > > > > > Oh, this patch missed the straightforward case: > > > > > > > > pg_basebackup -D data_N2 -d "user=3Dpostgres dbname=3Dreplication" = -R > > > > -> dbname would not be appeared in primary_conninfo. > > > > > > > > So I think it cannot be applied as-is. Sorry for sharing the bad it= em. > > > > > > > > > > Can you please share the patch that can be considered for review? > > > > Here is a patch with few changes: a) Removed the version check based > > on discussion from [1] b) updated the documentation. > > I have tested various scenarios with the attached patch, the dbname > > that is written in postgresql.auto.conf for each of the cases with > > pg_basebackup is given below: > > 1) ./pg_basebackup -U vignesh -R > > -> primary_conninfo =3D "dbname=3Dvignesh" (In this case primary_connin= fo > > will have dbname as username specified) > > 2) ./pg_basebackup -D data -R > > -> primary_conninfo =3D "dbname=3Dvignesh" (In this case primary_connin= fo > > will have the dbname as username (which is the same as the OS user > > while setting defaults)) > > 3) ./pg_basebackup -d "user=3Dvignesh" -D data -R > > -> primary_conninfo =3D "dbname=3Dreplication" (In this case > > primary_conninfo will have dbname as replication which is the default > > value from GetConnection as connection string is specified) > > 4) ./pg_basebackup -d "user=3Dvignesh dbname=3Dpostgres" -D data -R > > -> primary_conninfo =3D "dbname=3Dpostgres" (In this case primary_conni= nfo > > will have the dbname as the dbname specified) > > 5) ./pg_basebackup -d "" -D data -R > > -> primary_conninfo =3D "dbname=3Dreplication" (In this case > > primary_conninfo will have dbname as replication which is the default > > value from GetConnection as connection string is specified) > > > > I have mentioned the reasons as to why dbname is being set to > > replication or username in each of the cases. > > > > IIUC, the dbname is already allowed in connstring for pg_basebackup by > commit cca97ce6a6 and with this patch we are just writing it in > postgresql.auto.conf if -R option is used to write recovery info. This > will help slot syncworker to automatically connect with database > without user manually specifying the dbname and replication > connection, the same will still be ignored. I don't see any problem > with this. Does anyone else see any problem? > > The postgresql.auto.conf file will record the connec= tion > settings and, if specified, the replication slot > that pg_basebackup is using, so that > - streaming replication will use the same settings later on. > + a) synchronization of logical replication slots on the primary t= o the > + hot_standby from > + pg_sync_replication_slots or slot > sync worker > + and b) streaming replication will use the same settings later on= . > > We can simply modify the last line as: ".. streaming replication or > logical replication slots synchronization will use the same settings > later on." Additionally, you can give a link reference to [1]. Thanks for the comments, the attached v4 version patch has the changes for the same. Regards, Vignesh --00000000000079ad3806138cee9f Content-Type: text/x-patch; charset="US-ASCII"; name="pg_basebackup-write-dbname.v0004.patch" Content-Disposition: attachment; filename="pg_basebackup-write-dbname.v0004.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_ltpzrhk50 ZGlmZiAtLWdpdCBhL2RvYy9zcmMvc2dtbC9yZWYvcGdfYmFzZWJhY2t1cC5zZ21sIGIvZG9jL3Ny Yy9zZ21sL3JlZi9wZ19iYXNlYmFja3VwLnNnbWwKaW5kZXggODhjNjg5ZTcyNS4uNTYzMzQ2ZGQ3 MSAxMDA2NDQKLS0tIGEvZG9jL3NyYy9zZ21sL3JlZi9wZ19iYXNlYmFja3VwLnNnbWwKKysrIGIv ZG9jL3NyYy9zZ21sL3JlZi9wZ19iYXNlYmFja3VwLnNnbWwKQEAgLTI0Myw3ICsyNDMsOSBAQCBQ b3N0Z3JlU1FMIGRvY3VtZW50YXRpb24KICAgICAgICAgVGhlIDxmaWxlbmFtZT5wb3N0Z3Jlc3Fs LmF1dG8uY29uZjwvZmlsZW5hbWU+IGZpbGUgd2lsbCByZWNvcmQgdGhlIGNvbm5lY3Rpb24KICAg ICAgICAgc2V0dGluZ3MgYW5kLCBpZiBzcGVjaWZpZWQsIHRoZSByZXBsaWNhdGlvbiBzbG90CiAg ICAgICAgIHRoYXQgPGFwcGxpY2F0aW9uPnBnX2Jhc2ViYWNrdXA8L2FwcGxpY2F0aW9uPiBpcyB1 c2luZywgc28gdGhhdAotICAgICAgICBzdHJlYW1pbmcgcmVwbGljYXRpb24gd2lsbCB1c2UgdGhl IHNhbWUgc2V0dGluZ3MgbGF0ZXIgb24uCisgICAgICAgIHN0cmVhbWluZyByZXBsaWNhdGlvbiBv ciA8bGluayBsaW5rZW5kPSJsb2dpY2FsZGVjb2RpbmctcmVwbGljYXRpb24tc2xvdHMtc3luY2hy b25pemF0aW9uIj4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