Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d1zxW-00038P-K7 for pgsql-hackers@arkaria.postgresql.org; Sat, 22 Apr 2017 18:40:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d1zxV-0003Ik-Ma for pgsql-hackers@arkaria.postgresql.org; Sat, 22 Apr 2017 18:40:37 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d1zxT-0003HG-WB for pgsql-hackers@postgresql.org; Sat, 22 Apr 2017 18:40:36 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d1zxR-00082g-Hl for pgsql-hackers@postgresql.org; Sat, 22 Apr 2017 18:40:34 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v3MIeSTe021433; Sat, 22 Apr 2017 14:40:28 -0400 From: Tom Lane To: Thomas Munro cc: Simon Riggs , Alvaro Herrera , Pg Hackers Subject: Re: [COMMITTERS] pgsql: Replication lag tracking for walsenders In-reply-to: <4219.1492875661@sss.pgh.pa.us> References: <20170421190629.3srqyohjocgdvhhr@alvherre.pgsql> <27895.1492808648@sss.pgh.pa.us> <4219.1492875661@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sat, 22 Apr 2017 11:41:01 -0400" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <21401.1492886397.0@sss.pgh.pa.us> Date: Sat, 22 Apr 2017 14:40:28 -0400 Message-ID: <21432.1492886428@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <21401.1492886397.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable I wrote: > Whoa. This just turned into a much larger can of worms than I expected. > How can it be that processes are getting assertion crashes and yet the > test framework reports success anyway? That's impossibly > broken/unacceptable. I poked into this on my laptop, where I'm able to reproduce both assertion failures. The reason the one in subtrans.c is not being detected by the test framework is that it happens late in the run and the test doesn't do anything more with that server than shut it down. "pg_ctl stop" actually notices there's a problem; for instance, the log on tern for this step shows ### Stopping node "master" using mode immediate # Running: pg_ctl -D /home/nm/farm/gcc32/HEAD/pgsql.build/src/test/recovery= /tmp_check/data_master_xHGA/pgdata -m immediate stop pg_ctl: PID file "/home/nm/farm/gcc32/HEAD/pgsql.build/src/test/recovery/tm= p_check/data_master_xHGA/pgdata/postmaster.pid" does not exist Is server running? # No postmaster PID However, PostgresNode::stop blithely ignores the failure exit from pg_ctl. I think it should use system_or_bail() not just system_log(), so that we'll notice if the server is not running when we expect it to be. It's conceivable that there should also be a "stop_if_running" method that allows the case where the server is not running, but so far as I can find, no existing TAP test needs such a behavior --- and it certainly shouldn't be the default. The walsender.c crash is harder to detect because the postmaster very nicely recovers and restarts its children. That's great for robustness, but it sucks for testing. I think that we ought to disable that in TAP tests, which we can do by having PostgresNode::init include "restart_after_crash =3D off" in the postgresql.conf modifications it applies. Again, it's conceivable that some tests would not want that, but there is no existing test that seems to need crash recovery on, and I don't see a good argument for it being default for test purposes. As best I've been able to tell, the reason why the walsender.c crash is detected when it's detected is that the TAP script chances to try to connect while the recovery is happening: connection error: 'psql: FATAL: the database system is in recovery mode' while running 'psql -XAtq -d port=3D57718 host=3D/tmp/_uP8FKEynq dbname=3D'= postgres' -f - -v ON_ERROR_STOP=3D1' at /home/nm/farm/gcc32/HEAD/pgsql.buil= d/src/test/recovery/../../../src/test/perl/PostgresNode.pm line 1173. The window for that is not terribly wide, explaining why the detection is unreliable even when the crash does occur. In short then, I propose the attached patch to make these cases fail more reliably. We might extend this later to allow the old behaviors to be explicitly opted-into, but we don't seem to need that today. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="detect-server-crashes-in-tap-tests.patch"; charset="us-ascii" Content-ID: <21401.1492886397.2@sss.pgh.pa.us> Content-Description: detect-server-crashes-in-tap-tests.patch diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm index cb84f1f..f8a0581 100644 --- a/src/test/perl/PostgresNode.pm +++ b/src/test/perl/PostgresNode.pm @@ -402,6 +402,7 @@ sub init open my $conf, '>>', "$pgdata/postgresql.conf"; print $conf "\n# Added by PostgresNode.pm\n"; print $conf "fsync = off\n"; + print $conf "restart_after_crash = off\n"; print $conf "log_line_prefix = '%m [%p] %q%a '\n"; print $conf "log_statement = all\n"; print $conf "port = $port\n"; @@ -675,7 +676,7 @@ sub stop $mode = 'fast' unless defined $mode; return unless defined $self->{_pid}; print "### Stopping node \"$name\" using mode $mode\n"; - TestLib::system_log('pg_ctl', '-D', $pgdata, '-m', $mode, 'stop'); + TestLib::system_or_bail('pg_ctl', '-D', $pgdata, '-m', $mode, 'stop'); $self->{_pid} = undef; $self->_update_pid; } ------- =_aaaaaaaaaa0 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers ------- =_aaaaaaaaaa0--