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 1vIkVa-00CuaW-21 for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Nov 2025 09:17:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vIkVY-00577m-1P for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Nov 2025 09:17:48 +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 1vIkVX-00577d-1b for pgsql-hackers@lists.postgresql.org; Tue, 11 Nov 2025 09:17:48 +0000 Received: from fout-a8-smtp.messagingengine.com ([103.168.172.151]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1vIkVV-006WXE-0F for pgsql-hackers@lists.postgresql.org; Tue, 11 Nov 2025 09:17:46 +0000 Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailfout.phl.internal (Postfix) with ESMTP id D78BAEC010C; Tue, 11 Nov 2025 04:17:43 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-11.internal (MEProxy); Tue, 11 Nov 2025 04:17:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kurilemu.de; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to; s=fm2; t=1762852663; x= 1762939063; bh=BjP/3CBBW/bEcBIuI95nSY//G1Bi1pSh7P4hj/O8K9o=; b=Z GUNamimkwONjMYTrFfVEjxiwJPiPirgApD/yALvZOoBooJLY71hIj531hX0Yb5w3 EQITOV3/BeEl1lLfgNTRw6KRY+F56fb6gMp60EksaB22BC3GB0fxyglXZGhAFoQC bRm3eH48C8SgClXoH1uBoAj1K13gfFqiLK3M/1K2gmdVp3Bj3HRujsUso+NG2MUy F+4YgtTZVoVZpT1TECc3zgtUN41dAjdHSPQMOhEZODK1JWIaxHwmZgFAiREniB2I cZ9CfDHgkjNyffbfahoigkzvGkM9kdR5wEV5ycc+SsZTi9cV7C7OaX4FHrhi5qik a/RideuZDt7r4L5k1R7IA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1762852663; x=1762939063; bh=B jP/3CBBW/bEcBIuI95nSY//G1Bi1pSh7P4hj/O8K9o=; b=sdnqEkVMZBXShP2Y9 jPVR7F66q6CFT+eZ/Uz55ELroyS+GLWbmr567pilqYVnV6ngH3jyEPnQNxE90QIP nrOlyr6fj0+zmG4wCRYTzwbM+6JKOTCP62FhXPqWmCS+ZGbF1RcGF0+CIBCacMZp VOGI1qhi60oRHuCJXPHveRNe6bnJ85Wr+My+VkBsmFUvLPl6f1doO5oU3v5pzLjX z4CsoIaoJom0/0M5MIftWfKQz8feLtq9KQYjn8r8ABwn5q4MLtMYfC4/smaX7K7q p3XKfZv6+dMniHzCLQf0axU9e28Hzaprb6mBIJpOYj7LzIWueGVXmfURzQCCi1I6 kj94A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvtddtkeduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkgggtugfgjgesmhekreertddtjeenucfhrhhomheplmhlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsehkuhhrihhlvghmuhdruggvqeenucggtf frrghtthgvrhhnpeegudetudejheduveevgeehjeegleevveevvdeutdejtdekuefhheeh geevtdejteenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgv sehkuhhrihhlvghmuhdruggvpdhnsggprhgtphhtthhopeehpdhmohguvgepshhmthhpoh huthdprhgtphhtthhopegvuhhlvghrsegvuhhlvghrthhordgtohhmpdhrtghpthhtohep khhurhhouggrrdhhrgihrghtohesfhhujhhithhsuhdrtghomhdprhgtphhtthhopehlih drvghvrghnrdgthhgrohesghhmrghilhdrtghomhdprhgtphhtthhopehsmhhithhhphgs vddvhedtsehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsh eslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: ie3de48e3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 11 Nov 2025 04:17:42 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kurilemu.de; s=schmee; t=1762852661; bh=YWYz5zDzI/e43SBS2l5oqkQy7VPeaLw2yc+v2KJRcmU=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=pmS3gnPrb2bWH79CSdqs/0zkbaMm3lHM5Dgr/LbjIsLjssFM8+waK3o3kEZZsvuQT es2OOIwvyqNgXS2ClF4XixS8ZT820/bFjENuRAkkkvcSRJKibN+mek5rsVoqUIMtu6 XnkFEH0CiXfL9imUcgWdQQ4PfT0Yfrjnl1d1p8+1G17Q6giTv0Khg+oFl9bgC/O3ZA 99sY/aFgMqWbnplO8vpKrGc84OSI82jfmy4xoebAiBP3xrEWVk24jGNxCFOMmOlvKR qoJzDqvhEKu5/XeHyvEimUOCfUbNMGXsymughJRpaY4o0hBexNSpNxTaffj0i2cN9/ p+jGIQx/Plzaw== Received: by schmee.kurilemu.internal (Postfix, from userid 1000) id 320AA76; Tue, 11 Nov 2025 11:17:41 +0200 (EET) Date: Tue, 11 Nov 2025 10:17:41 +0100 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: Peter Smith Cc: Chao Li , Euler Taveira , "kuroda.hayato@fujitsu.com" , PostgreSQL Hackers Subject: Re: pg_createsubscriber --dry-run logging concerns Message-ID: <202511110904.ea4rsawszq65@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ibfr3ah5qy6tcbhw" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --ibfr3ah5qy6tcbhw Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2025-Nov-10, Peter Smith wrote: > Hi Alvaro, > > Here is patch v4-0001 modified as requested: > - dashes are removed > - the message is a single string Okay, thanks. I split the strings in two lines, as we customarily do when they contain embedded newlines. I also noticed pg_resetwal uses stdout rather than stderr and set out to change it, because I don't think it's sensible to have one program behave one way (print to stdout) when all others behave in another (to stderr). I wrote a commit message and was about ready to push. However, I then found out that the reason you used stdout instead of stderr in pg_resetwal is that with the latter, tests fail all over the place because of pg_resetwal -n being used for pg_upgrade internally via popen(), and making it write to stderr results in confusing pg_upgrade output as well as test failures. A very simple fix for this problem would be, of course, to add " 2>/dev/null" to the popen call, but that is not only cheating, it is also dangerous: if pg_resetwal ever finds reason to complain, we won't get very good information because of that redirection. (I also don't think this line belongs in stdout, in case you're thinking of changing it in the other direction for all other programs.) Maybe we should add a -q,--silent mode that suppresses the "Running in dry-run mode" line. I do wonder if this is getting too far into the weeds for such a small thing. I won't blame you if you want to just drop this whole idea, but I also won't stop you if you want to introduce --silent. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "No necesitamos banderas No reconocemos fronteras" (Jorge González) --ibfr3ah5qy6tcbhw Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="v5-0001-Log-a-note-at-program-start-when-running-in-dry-r.patch" Content-Transfer-Encoding: 8bit From ebb8b62d2fa0c668f47b2e87b42587fd790a3263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Herrera?= Date: Tue, 11 Nov 2025 09:54:19 +0100 Subject: [PATCH v5] Log a note at program start when running in dry-run mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Users might get some peace of mind knowing their data is not being destroyed or whatever. Author: Peter Smith Reviewed-by: Álvaro Herrera Discussion: https://postgr.es/m/CAHut+PsvQJQnQO0KT0S2oegenkvJ8FUuY-QS5syyqmT24R2xFQ@mail.gmail.com --- src/bin/pg_archivecleanup/pg_archivecleanup.c | 4 ++++ src/bin/pg_basebackup/pg_createsubscriber.c | 5 +++++ src/bin/pg_combinebackup/pg_combinebackup.c | 4 ++++ src/bin/pg_resetwal/pg_resetwal.c | 4 ++++ src/bin/pg_rewind/pg_rewind.c | 10 ++++++---- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/bin/pg_archivecleanup/pg_archivecleanup.c b/src/bin/pg_archivecleanup/pg_archivecleanup.c index c25348bcb85..ab686b4748c 100644 --- a/src/bin/pg_archivecleanup/pg_archivecleanup.c +++ b/src/bin/pg_archivecleanup/pg_archivecleanup.c @@ -375,6 +375,10 @@ main(int argc, char **argv) exit(2); } + if (dryrun) + pg_log_info("Executing in dry-run mode.\n" + "No files will be removed."); + /* * Check archive exists and other initialization if required. */ diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c index df41836e70f..cc4be5d6ef4 100644 --- a/src/bin/pg_basebackup/pg_createsubscriber.c +++ b/src/bin/pg_basebackup/pg_createsubscriber.c @@ -2305,6 +2305,11 @@ main(int argc, char **argv) pg_log_error_hint("Try \"%s --help\" for more information.", progname); exit(1); } + + if (dry_run) + pg_log_info("Executing in dry-run mode.\n" + "The target directory will not be modified."); + pg_log_info("validating publisher connection string"); pub_base_conninfo = get_base_conninfo(opt.pub_conninfo_str, &dbname_conninfo); diff --git a/src/bin/pg_combinebackup/pg_combinebackup.c b/src/bin/pg_combinebackup/pg_combinebackup.c index 3a325127209..c9bf0a9e105 100644 --- a/src/bin/pg_combinebackup/pg_combinebackup.c +++ b/src/bin/pg_combinebackup/pg_combinebackup.c @@ -242,6 +242,10 @@ main(int argc, char *argv[]) if (opt.no_manifest) opt.manifest_checksums = CHECKSUM_TYPE_NONE; + if (opt.dry_run) + pg_log_info("Executing in dry-run mode.\n" + "The target directory will not be modified."); + /* Check that the platform supports the requested copy method. */ if (opt.copy_method == COPY_METHOD_CLONE) { diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c index a89d72fc5cf..dd5d279521e 100644 --- a/src/bin/pg_resetwal/pg_resetwal.c +++ b/src/bin/pg_resetwal/pg_resetwal.c @@ -397,6 +397,10 @@ main(int argc, char *argv[]) exit(1); } + if (noupdate) + pg_log_info("Executing in dry-run mode.\n" + "Nothing will be modified."); + /* * Attempt to read the existing pg_control file */ diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c index 27c514f934a..e9364d04f76 100644 --- a/src/bin/pg_rewind/pg_rewind.c +++ b/src/bin/pg_rewind/pg_rewind.c @@ -300,10 +300,12 @@ main(int argc, char **argv) atexit(disconnect_atexit); - /* - * Ok, we have all the options and we're ready to start. First, connect to - * remote server. - */ + /* Ok, we have all the options and we're ready to start. */ + if (dry_run) + pg_log_info("Executing in dry-run mode.\n" + "The target directory will not be modified."); + + /* First, connect to remote server. */ if (connstr_source) { conn = PQconnectdb(connstr_source); -- 2.47.3 --ibfr3ah5qy6tcbhw--