Fix unnecessary includes and comments in 019_replslot_limit.pl, 007_wal.pl and 004_timeline_switch.pl

Started by Bharath Rupireddyover 3 years ago6 messages
#1Bharath Rupireddy
bharath.rupireddyforpostgres@gmail.com
1 attachment(s)

Hi,

While working on a feature, I noticed that there are unnecessary
includes of "use File::Path qw(rmtree);" in some TAP test files and
also some wrong comments in 019_replslot_limit.pl. Attaching a patch
to fix these.

Regards,
Bharath Rupireddy.

Attachments:

v1-0001-Fix-unnecessary-includes-and-comments-in-019_repl.patchapplication/octet-stream; name=v1-0001-Fix-unnecessary-includes-and-comments-in-019_repl.patchDownload
From e3ff2e744edc0cd4d6717d8af2b5f870515264a6 Mon Sep 17 00:00:00 2001
From: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Date: Sat, 21 May 2022 07:37:31 +0000
Subject: [PATCH v1] Fix unnecessary includes and comments in
 019_replslot_limit.pl, 007_wal.pl and 004_timeline_switch.pl

---
 src/bin/pg_verifybackup/t/007_wal.pl       | 1 -
 src/test/recovery/t/004_timeline_switch.pl | 1 -
 src/test/recovery/t/019_replslot_limit.pl  | 6 ++----
 3 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/bin/pg_verifybackup/t/007_wal.pl b/src/bin/pg_verifybackup/t/007_wal.pl
index 6e9fafcd55..9a21e8dc15 100644
--- a/src/bin/pg_verifybackup/t/007_wal.pl
+++ b/src/bin/pg_verifybackup/t/007_wal.pl
@@ -5,7 +5,6 @@
 
 use strict;
 use warnings;
-use File::Path qw(rmtree);
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
 use Test::More;
diff --git a/src/test/recovery/t/004_timeline_switch.pl b/src/test/recovery/t/004_timeline_switch.pl
index 3203d93701..f946ce9f1c 100644
--- a/src/test/recovery/t/004_timeline_switch.pl
+++ b/src/test/recovery/t/004_timeline_switch.pl
@@ -4,7 +4,6 @@
 # Test for timeline switch
 use strict;
 use warnings;
-use File::Path qw(rmtree);
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
 use Test::More;
diff --git a/src/test/recovery/t/019_replslot_limit.pl b/src/test/recovery/t/019_replslot_limit.pl
index 6bbf55c3ee..39e315ba8b 100644
--- a/src/test/recovery/t/019_replslot_limit.pl
+++ b/src/test/recovery/t/019_replslot_limit.pl
@@ -9,8 +9,6 @@ use warnings;
 
 use PostgreSQL::Test::Utils;
 use PostgreSQL::Test::Cluster;
-
-use File::Path qw(rmtree);
 use Test::More;
 use Time::HiRes qw(usleep);
 
@@ -60,7 +58,7 @@ $result = $node_primary->safe_psql('postgres',
 );
 is($result, "reserved|t", 'check the catching-up state');
 
-# Advance WAL by five segments (= 5MB) on primary
+# Advance WAL by 1 segment (= 1MB) on primary
 advance_wal($node_primary, 1);
 $node_primary->safe_psql('postgres', "CHECKPOINT;");
 
@@ -434,7 +432,7 @@ sub advance_wal
 {
 	my ($node, $n) = @_;
 
-	# Advance by $n segments (= (16 * $n) MB) on primary
+	# Advance by $n segments (= (wal_segment_size * $n) MB) on primary
 	for (my $i = 0; $i < $n; $i++)
 	{
 		$node->safe_psql('postgres',
-- 
2.25.1

#2Maxim Orlov
orlovmg@gmail.com
In reply to: Bharath Rupireddy (#1)
Re: Fix unnecessary includes and comments in 019_replslot_limit.pl, 007_wal.pl and 004_timeline_switch.pl

Hi!

This is an obvious change, I totally for it. Hope it will be commited soon.

--
Best regards,
Maxim Orlov.

#3Pavel Borisov
pashkin.elfe@gmail.com
In reply to: Maxim Orlov (#2)
1 attachment(s)
Re: Fix unnecessary includes and comments in 019_replslot_limit.pl, 007_wal.pl and 004_timeline_switch.pl

On Wed, Jul 6, 2022 at 5:05 PM Maxim Orlov <orlovmg@gmail.com> wrote:

Hi!

This is an obvious change, I totally for it. Hope it will be commited soon.

I'm sorry for some nitpicking about changes in the comments:
- The number of WAL segments advanced hasn't changed from 5 to 1, it just
advances as 1+4 as previously. So the original comment is right. I reverted
this in v2.
- wal_segment_size is in bytes so comment "(wal_segment_size * n) MB" is
incorrect. I corrected this to bytes.

PFA v2 of a patch (only comments changed/reverted to original).
Overall I completely agree with Maxim: the patch is good and simple enough
to be RfC.

--
Best regards,
Pavel Borisov

Postgres Professional: http://postgrespro.com <http://www.postgrespro.com&gt;

Attachments:

v2-0001-Fix-unnecessary-includes-and-comments-in-019_repl.patchapplication/octet-stream; name=v2-0001-Fix-unnecessary-includes-and-comments-in-019_repl.patchDownload
From 797177801812c1a2cbea59675de14a9ed9ae36ae Mon Sep 17 00:00:00 2001
From: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Date: Sat, 21 May 2022 07:37:31 +0000
Subject: [PATCH v2] Fix unnecessary includes and comments in
 019_replslot_limit.pl, 007_wal.pl and 004_timeline_switch.pl

---
 src/bin/pg_verifybackup/t/007_wal.pl       | 1 -
 src/test/recovery/t/004_timeline_switch.pl | 1 -
 src/test/recovery/t/019_replslot_limit.pl  | 4 +---
 3 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/bin/pg_verifybackup/t/007_wal.pl b/src/bin/pg_verifybackup/t/007_wal.pl
index 6e9fafcd55a..9a21e8dc152 100644
--- a/src/bin/pg_verifybackup/t/007_wal.pl
+++ b/src/bin/pg_verifybackup/t/007_wal.pl
@@ -5,7 +5,6 @@
 
 use strict;
 use warnings;
-use File::Path qw(rmtree);
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
 use Test::More;
diff --git a/src/test/recovery/t/004_timeline_switch.pl b/src/test/recovery/t/004_timeline_switch.pl
index 3203d937016..f946ce9f1c7 100644
--- a/src/test/recovery/t/004_timeline_switch.pl
+++ b/src/test/recovery/t/004_timeline_switch.pl
@@ -4,7 +4,6 @@
 # Test for timeline switch
 use strict;
 use warnings;
-use File::Path qw(rmtree);
 use PostgreSQL::Test::Cluster;
 use PostgreSQL::Test::Utils;
 use Test::More;
diff --git a/src/test/recovery/t/019_replslot_limit.pl b/src/test/recovery/t/019_replslot_limit.pl
index 84c9c4b0b3c..5cb194caa63 100644
--- a/src/test/recovery/t/019_replslot_limit.pl
+++ b/src/test/recovery/t/019_replslot_limit.pl
@@ -9,8 +9,6 @@ use warnings;
 
 use PostgreSQL::Test::Utils;
 use PostgreSQL::Test::Cluster;
-
-use File::Path qw(rmtree);
 use Test::More;
 use Time::HiRes qw(usleep);
 
@@ -429,7 +427,7 @@ sub advance_wal
 {
 	my ($node, $n) = @_;
 
-	# Advance by $n segments (= (16 * $n) MB) on primary
+	# Advance by $n segments (= (wal_segment_size * $n) bytes) on primary
 	for (my $i = 0; $i < $n; $i++)
 	{
 		$node->safe_psql('postgres',
-- 
2.24.3 (Apple Git-128)

#4Maxim Orlov
orlovmg@gmail.com
In reply to: Pavel Borisov (#3)
Re: Fix unnecessary includes and comments in 019_replslot_limit.pl, 007_wal.pl and 004_timeline_switch.pl

I'm sorry for some nitpicking about changes in the comments:
- The number of WAL segments advanced hasn't changed from 5 to 1, it just
advances as 1+4 as previously. So the original comment is right. I reverted
this in v2.

Yeah, it looks even better now.

--
Best regards,
Maxim Orlov.

#5Michael Paquier
michael@paquier.xyz
In reply to: Maxim Orlov (#4)
Re: Fix unnecessary includes and comments in 019_replslot_limit.pl, 007_wal.pl and 004_timeline_switch.pl

On Wed, Jul 06, 2022 at 04:26:38PM +0300, Maxim Orlov wrote:

Yeah, it looks even better now.

Especially knowing that the test uses a segment size of 1MB via initdb
to be cheaper. v2 looks fine by itself, so applied.
--
Michael

#6Pavel Borisov
pashkin.elfe@gmail.com
In reply to: Michael Paquier (#5)
Re: Fix unnecessary includes and comments in 019_replslot_limit.pl, 007_wal.pl and 004_timeline_switch.pl

Especially knowing that the test uses a segment size of 1MB via initdb
to be cheaper. v2 looks fine by itself, so applied.

Thanks, Michael!

--
Best regards,
Pavel Borisov

Postgres Professional: http://postgrespro.com <http://www.postgrespro.com&gt;