public inbox for [email protected]
help / color / mirror / Atom feed[PATCH 2/2] the test
3+ messages / 2 participants
[nested] [flat]
* [PATCH 2/2] the test
@ 2021-06-10 20:44 Alvaro Herrera <[email protected]>
0 siblings, 0 replies; 3+ messages in thread
From: Alvaro Herrera @ 2021-06-10 20:44 UTC (permalink / raw)
---
src/test/recovery/t/019_replslot_limit.pl | 73 ++++++++++++++++++++++-
1 file changed, 70 insertions(+), 3 deletions(-)
diff --git a/src/test/recovery/t/019_replslot_limit.pl b/src/test/recovery/t/019_replslot_limit.pl
index 7094aa0704..fa47c915a5 100644
--- a/src/test/recovery/t/019_replslot_limit.pl
+++ b/src/test/recovery/t/019_replslot_limit.pl
@@ -11,7 +11,7 @@ use TestLib;
use PostgresNode;
use File::Path qw(rmtree);
-use Test::More tests => 14;
+use Test::More tests => 17;
use Time::HiRes qw(usleep);
$ENV{PGDATABASE} = 'postgres';
@@ -211,8 +211,8 @@ for (my $i = 0; $i < 10000; $i++)
}
ok($failed, 'check that replication has been broken');
-$node_primary->stop('immediate');
-$node_standby->stop('immediate');
+$node_primary->stop;
+$node_standby->stop;
my $node_primary2 = get_new_node('primary2');
$node_primary2->init(allows_streaming => 1);
@@ -253,6 +253,73 @@ my @result =
timeout => '60'));
is($result[1], 'finished', 'check if checkpoint command is not blocked');
+$node_primary2->stop;
+$node_standby->stop;
+
+# The next test depends on Perl's `kill`, which apparently is not
+# portable to Windows. (It would be nice to use Test::More's `subtest`,
+# but that's not in the ancient version we require.)
+done_testing() if $TestLib::windows_os;
+
+# Get a slot terminated while the walsender is active
+# We do this by sending SIGSTOP to the walreceiver. Skip this on Windows.
+my $node_primary3 = get_new_node('primary3');
+$node_primary3->init(allows_streaming => 1, extra => ['--wal-segsize=1']);
+$node_primary3->append_conf(
+ 'postgresql.conf', qq(
+ min_wal_size = 2MB
+ max_wal_size = 2MB
+ log_checkpoints = yes
+ max_slot_wal_keep_size = 1MB
+ ));
+$node_primary3->start;
+$node_primary3->safe_psql('postgres',
+ "SELECT pg_create_physical_replication_slot('rep3')");
+# Take backup
+$backup_name = 'my_backup';
+$node_primary3->backup($backup_name);
+# Create standby
+my $node_standby3 = get_new_node('standby_3');
+$node_standby3->init_from_backup($node_primary3, $backup_name,
+ has_streaming => 1);
+$node_standby3->append_conf('postgresql.conf', "primary_slot_name = 'rep3'");
+$node_standby3->start;
+$node_primary3->wait_for_catchup($node_standby3->name, 'replay');
+my $pid = $node_standby3->safe_psql('postgres',
+ "SELECT pid FROM pg_stat_activity WHERE backend_type = 'walreceiver'");
+like($pid, qr/^[0-9]+$/, "have walreceiver pid $pid");
+
+# freeze walreceiver. Slot will still be active, but it won't advance
+kill 'STOP', $pid;
+$logstart = get_log_size($node_primary3);
+advance_wal($node_primary3, 2);
+
+my ($in, $out, $timer, $h);
+$timer = IPC::Run::timeout(180);
+$h = $node_primary3->background_psql('postgres', \$in, \$out, $timer);
+$in .= qq{
+checkpoint;
+};
+$h->pump_nb;
+ok( find_in_log($node_primary3,
+ "to release replication slot"),
+ "walreceiver termination logged");
+
+# Now let it continue to its demise
+kill 'CONT', $pid;
+
+$node_primary3->poll_query_until('postgres',
+ "SELECT wal_status FROM pg_replication_slots WHERE slot_name = 'rep3'",
+ "lost") or die "timed out waiting for slot to be lost";
+
+ok( find_in_log($node_primary3,
+ 'invalidating slot "rep3" because its restart_lsn'),
+ "slot invalidation logged");
+
+
+$node_primary3->stop;
+$node_standby3->stop;
+
#####################################
# Advance WAL of $node by $n segments
sub advance_wal
--
2.20.1
--6s6fi4xhi7ezemxn--
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Psql meta-command conninfo+
@ 2024-09-14 12:28 Hunaid Sohail <[email protected]>
2024-09-14 17:37 ` Re: Psql meta-command conninfo+ Alvaro Herrera <[email protected]>
0 siblings, 1 reply; 3+ messages in thread
From: Hunaid Sohail @ 2024-09-14 12:28 UTC (permalink / raw)
To: Jim Jones <[email protected]>; +Cc: Alvaro Herrera <[email protected]>; Maiquel Grassi <[email protected]>; Nathan Bossart <[email protected]>; Imseih (AWS), Sami <[email protected]>; Peter Eisentraut <[email protected]>; Tom Lane <[email protected]>; Pavel Luzanov <[email protected]>; Erik Wienhold <[email protected]>; pgsql-hackers
Hi Jim,
On Fri, Sep 13, 2024 at 4:27 PM Jim Jones <[email protected]> wrote:
> I just noticed that messages' order has been slightly changed. The
> message "You are connected to database "postgres" as user "hunaid" via
> socket in "/tmp" at port "5430" used to be printed after the table, and
> now it is printed before.
>
> $ /usr/local/postgres-dev/bin/psql -x "\
> hostaddr=0
> user=jim dbname=postgres
> port=54322" -c "\conninfo+"
>
> You are connected to database "postgres" as user "jim" on host "0"
> (address "0.0.0.0") at port "54322".
> Connection Information
> -[ RECORD 1 ]--------+--------
> Protocol Version | 3
> SSL Connection | no
> GSSAPI Authenticated | no
> Client Encoding | UTF8
> Server Encoding | UTF8
> Session User | jim
> Backend PID | 2419033
>
> It is IMHO a little strange because the "SSL connection" info keeps
> being printed in the end. I would personally prefer if they're printed
> together --- preferably after the table. But I'm not sure if there's any
> convention for that.
>
I agree that both messages should be printed together. IMO the message
"You are connected to database..." should be printed at the top, no?
Because it shows important info that the user may be interested to see
first. Then we can combine the ssl message.
postgres=# \x
Expanded display is on.
postgres=# \conninfo+
You are connected to database "postgres" as user "hunaid" on host
"localhost" (address "127.0.0.1") at port "5430".
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384,
compression: off, ALPN: postgresql)
Connection Information
-[ RECORD 1 ]--------+-------
Protocol Version | 3
SSL Connection | yes
GSSAPI Authenticated | no
Client Encoding | UTF8
Server Encoding | UTF8
Session User | hunaid
Backend PID | 109092
> Also, there are a few compilation warnings regarding const qualifiers:
>
Noted. I will fix them in the next patch.
Regards,
Hunaid Sohail
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Psql meta-command conninfo+
2024-09-14 12:28 Re: Psql meta-command conninfo+ Hunaid Sohail <[email protected]>
@ 2024-09-14 17:37 ` Alvaro Herrera <[email protected]>
0 siblings, 0 replies; 3+ messages in thread
From: Alvaro Herrera @ 2024-09-14 17:37 UTC (permalink / raw)
To: Hunaid Sohail <[email protected]>; +Cc: Jim Jones <[email protected]>; Maiquel Grassi <[email protected]>; Nathan Bossart <[email protected]>; Imseih (AWS), Sami <[email protected]>; Peter Eisentraut <[email protected]>; Tom Lane <[email protected]>; Pavel Luzanov <[email protected]>; Erik Wienhold <[email protected]>; pgsql-hackers
On 2024-Sep-14, Hunaid Sohail wrote:
> I agree that both messages should be printed together. IMO the message
> "You are connected to database..." should be printed at the top, no?
> Because it shows important info that the user may be interested to see
> first. Then we can combine the ssl message.
>
> postgres=# \x
> Expanded display is on.
> postgres=# \conninfo+
> You are connected to database "postgres" as user "hunaid" on host
> "localhost" (address "127.0.0.1") at port "5430".
> SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384,
> compression: off, ALPN: postgresql)
> Connection Information
> -[ RECORD 1 ]--------+-------
> Protocol Version | 3
> SSL Connection | yes
> GSSAPI Authenticated | no
> Client Encoding | UTF8
> Server Encoding | UTF8
> Session User | hunaid
> Backend PID | 109092
I don't understand why this is is printing half the information in
free-form plain text and the other half in tabular format. All these
items that you have in the free-form text lines should be part of the
table, I think.
--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
#error "Operator lives in the wrong universe"
("Use of cookies in real-time system development", M. Gleixner, M. Mc Guire)
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2024-09-14 17:37 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-06-10 20:44 [PATCH 2/2] the test Alvaro Herrera <[email protected]>
2024-09-14 12:28 Re: Psql meta-command conninfo+ Hunaid Sohail <[email protected]>
2024-09-14 17:37 ` Re: Psql meta-command conninfo+ Alvaro Herrera <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox