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 1rkMmf-00CDvz-5D for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Mar 2024 11:28:33 +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 1rkMmc-0018j3-Uy for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Mar 2024 11:28:31 +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 1rkMmc-0018iv-K5 for pgsql-hackers@lists.postgresql.org; Wed, 13 Mar 2024 11:28:31 +0000 Received: from mail-oa1-x2d.google.com ([2001:4860:4864:20::2d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rkMmV-004Htf-LF for pgsql-hackers@postgresql.org; Wed, 13 Mar 2024 11:28:30 +0000 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-2222b96e4d2so775785fac.3 for ; Wed, 13 Mar 2024 04:28:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710329302; x=1710934102; 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=k4hgZlbg92VUo1NdKs9upZ1f+N8B/65bZMf9XwmjUFo=; b=UWntlzU8FB0Br6VYAA+MHj16gtyHkV5HjEVpTI2VK9VMl1+0VZHsCz8UUXASqbdCNR hd+29fmoCR8G+Ks4/1Yo44evoEUjkymt9Xx9A+kZH9dphTPDQq0LXsEA0cdYTP+hDogX OIr8tD7pMEJuNb1l0jnltbj8Ct9GWZrLUrpcavpF+0et8olqvdDHZa8NrjxpaCuAyZ+M 13iq1O+bRBfNbKgiK8Ahit35IQyotUrDV9zjnIc160dOLGIh2ZG18Cb04DVGYElINkz9 onGXk7egnV+qw+BYL+z0+inLctmhC2L3TaK/crPzU5uMxGRvafLs0U5ekLc6o/RW5rIA YFvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710329302; x=1710934102; 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=k4hgZlbg92VUo1NdKs9upZ1f+N8B/65bZMf9XwmjUFo=; b=DrcGrnh4/QBwsY7uyk+opNbskbEe3Grsdfqmdahf2Q5/ASIpurZZ9fd5ztsSHsioAR zJaOJ89G+jAiyCq5Buox5nb30jCWybCcrx2lg9Eoa6L5kaEwWuaYUUE64swZYXaFdilV aBw+fvntAZcJ8BibRNqH/SJooO3xZX1Cm15F6JnVvHyf4usBPufjqfeyCjgqliWr5Kf8 0lmXufOsTcrTk0l4qwA4yulSTV1SYL/O+TjfpF0R99lRUMCti1eY+WGBVmkt0XEtSZ+F EAxw02CHmuWpN0gqDxgHzm0aPtsYDQdpR2Kny0tCMcmH2jp8awFsXl57842OQNT8Vv60 Aytg== X-Forwarded-Encrypted: i=1; AJvYcCWSyTyDZJT/tMMxrwMMlA7D3A5ffpErtzxK6ILvH7K+NB/AfampsiZGuiP46/Fp7RNN4mUuEcFFIeFxgtkx9s3eqTH6Cz5qEYXOBSQC X-Gm-Message-State: AOJu0YyrVZyEsuILLLQbGbCGwmX7vadN4f+KploFTPnP2uf9lqayuRq5 qS+ij3ysc8GwwhjBhgEW+qRElrjY1B7ninZ5CTr+W4e89ZJXSIPCnNvSkympordjBzFKERKOUm9 IclvshP9pF5XL7kngdB3PY4xWHWk= X-Google-Smtp-Source: AGHT+IGiLZ7bOxBq8qv44iOHsqzw+fxL1nPGZoHWgh5uDih8VjNRRU5UXRnxsmImHpNqyzAhR1DvDepRunQWDIh3PKE= X-Received: by 2002:a05:6870:b690:b0:21f:dc6e:e4dc with SMTP id cy16-20020a056870b69000b0021fdc6ee4dcmr11699703oab.5.1710329301518; Wed, 13 Mar 2024 04:28:21 -0700 (PDT) MIME-Version: 1.0 References: <20240221.120424.79274783106518358.horikyota.ntt@gmail.com> In-Reply-To: From: Amit Kapila Date: Wed, 13 Mar 2024 16:58:09 +0530 Message-ID: Subject: Re: Have pg_basebackup write "dbname" in "primary_conninfo"? To: vignesh C Cc: "Hayato Kuroda (Fujitsu)" , "robertmhaas@gmail.com" , "barwick@gmail.com" , "pgsql-hackers@postgresql.org" , Kyotaro Horiguchi 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 Tue, Mar 12, 2024 at 5:13=E2=80=AFPM vignesh C wro= te: > > On Mon, 11 Mar 2024 at 17:16, Amit Kapila wrote= : > > > > 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 on= e. > > > > 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() ex= plicy override > > > > a dbname to "replication". I've tried to add a dummy entry {"dbname= ", NULL} pair > > > > before the overriding, but it is no-op. Because The replacement of = the dbname in > > > > pqConnectOptions2() would be done only for the valid (=3Dlastly spe= cified) > > > > 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 item= . > > > > > > > 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_conninfo > will have dbname as username specified) > 2) ./pg_basebackup -D data -R > -> primary_conninfo =3D "dbname=3Dvignesh" (In this case primary_conninfo > 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_conninf= o > 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 connecti= on 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 to = 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]. [1] - https://www.postgresql.org/docs/devel/logicaldecoding-explanation.htm= l#LOGICALDECODING-REPLICATION-SLOTS-SYNCHRONIZATION --=20 With Regards, Amit Kapila.