Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jZjh4-0001N4-HP for pgsql-hackers@arkaria.postgresql.org; Fri, 15 May 2020 23:24:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jZjh3-00038r-9A for pgsql-hackers@arkaria.postgresql.org; Fri, 15 May 2020 23:24:41 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jZjh2-00036K-Tj for pgsql-hackers@lists.postgresql.org; Fri, 15 May 2020 23:24:41 +0000 Received: from mail-qk1-x743.google.com ([2607:f8b0:4864:20::743]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jZjgy-0001pu-HM for pgsql-hackers@lists.postgresql.org; Fri, 15 May 2020 23:24:39 +0000 Received: by mail-qk1-x743.google.com with SMTP id b6so4398209qkh.11 for ; Fri, 15 May 2020 16:24:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=2n4i9HeRGEWzak3DOXQUziz3KYxIwy0TcMtVJ4pFwrE=; b=L2njWUki8J0Np0HvtT4u0ZfwWJ6kPSKLmnuJ6YEJ9Hol6Noa8AZFRNVgnBx+CdSsay mxizzjW90Ys0OrvWaYYBAL1OyF1msZLqMoaLF3hyP5Z4LnAnTKQa50kyfq0D7Ffu6zHg n0h0h3k4SF7A63BiRAYILdc08aLrEbPOfTE3Hb9E3iPkJYIz5QbPyUOkTnWaWhmgnuZJ RiuxARPTMwzpL+pu3D80Ord7wfGe3gytabx77ydmQRalRnrrRs/X/js2igtZPnrboVgK cQ75w0O3KK/nA/1oS4X3UJnEaOSsPpg9W93qEYQoj9ek5IYcbhB9J4jG603NF6RDOybi Qmhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=2n4i9HeRGEWzak3DOXQUziz3KYxIwy0TcMtVJ4pFwrE=; b=f5+KLeN/Oi5xZJnFbMEQqzR3bj3a3jHXMHet/flsCyVslHY5iMMRmjgS33W3v1tW/7 ZweSFZs1Nd+1V2OUu5p5uhMtvdQ1t5Ss82pgfgB5wfriSM3oPzroO+7ItVGSivRMtb/Z dAbldbnM86w2kuSy50ZIKsfS5YtfVjb7VT/Dv4yttvGNsm+MepdD+w2vv+FVJX6QiYGG H0Wn6JJJ2bezg7c8rfULhnhhbV285Lebs22QfDjDx5k2d8pFf6YmybwkcHVix18spN3d EfuyDwpoKtS29VwK4/3SPNM9ecJZVghNoIWDITnyhfc4+KnejmtArZW2c3/ItaawMsZl c/Pg== X-Gm-Message-State: AOAM532oFuZGtzmWqg0tH2sw3VXjnqYOsDZ4lpmOXi2sPSDJSZrowrai +v2xG+0zRFqjFr/vajb4tqiV0Q== X-Google-Smtp-Source: ABdhPJw3qvOfAndIaGh1U5M3Z0mRjZKSpl1Aodmh4sc0t9d4OUV00c/2bsKtHnSuJbcUHunnbJHEWg== X-Received: by 2002:a37:496:: with SMTP id 144mr5914306qke.50.1589585075730; Fri, 15 May 2020 16:24:35 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.95.18.252]) by smtp.gmail.com with ESMTPSA id f198sm2749630qke.46.2020.05.15.16.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 16:24:34 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id C46B03006AF; Fri, 15 May 2020 19:24:28 -0400 (-04) Date: Fri, 15 May 2020 19:24:28 -0400 From: Alvaro Herrera To: Michael Paquier Cc: Kyotaro Horiguchi , bossartn@amazon.com, tgl@sss.pgh.pa.us, pgsql-hackers@lists.postgresql.org, ah@cybertec.at, andres@anarazel.de Subject: Re: pg13: xlogreader API adjust Message-ID: <20200515232428.GA31633@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="DocE+STaALJfprDB" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200515111858.GB212736@paquier.xyz> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --DocE+STaALJfprDB Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2020-May-15, Michael Paquier wrote: > On Thu, May 14, 2020 at 02:12:25PM +0900, Kyotaro Horiguchi wrote: > > Good catch! That's not only for CreateDecodingContet. That happens > > everywhere in the query loop in PostgresMain() until logreader is > > initialized. So that also happens, for example, by starting logical > > replication using invalidated slot. Checking xlogreader != NULL in > > WalSndErrorCleanup is sufficient. It doesn't make actual difference, > > but the attached explicitly initialize the pointer with NULL. > > Alvaro, are you planning to look at that? Should we have an open item > for this matter? On it now. I'm trying to add a test for this (needs a small change to PostgresNode->psql), but I'm probably doing something stupid in the Perl side, because it doesn't detect things as well as I'd like. Still trying, but I may be asked to evict the office soon ... -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --DocE+STaALJfprDB Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="crashtest.patch" diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm index 3f3a1d81f6..0645e07789 100644 --- a/src/test/perl/PostgresNode.pm +++ b/src/test/perl/PostgresNode.pm @@ -1386,6 +1386,12 @@ the B parameter is also given. If B is set and this parameter is given, the scalar it references is set to true if the psql call times out. +=item replication => B + +If set, pass the value as B in the conninfo string. +Passing literal B results in a logical replication connection. +Passing literal B<1> results in a physical replication connection. + =item extra_params => ['--single-transaction'] If given, it must be an array reference containing additional parameters to B. @@ -1414,10 +1420,14 @@ sub psql my $stdout = $params{stdout}; my $stderr = $params{stderr}; + my $replication = $params{replication}; my $timeout = undef; my $timeout_exception = 'psql timed out'; my @psql_params = - ('psql', '-XAtq', '-d', $self->connstr($dbname), '-f', '-'); + ('psql', '-XAtq', '-d', + $self->connstr($dbname) . + (defined $replication ? " replication=$replication" : ""), + '-f', '-'); # If the caller wants an array and hasn't passed stdout/stderr # references, allocate temporary ones to capture them so we diff --git a/src/test/recovery/t/006_logical_decoding.pl b/src/test/recovery/t/006_logical_decoding.pl index d40a500ed4..5c7e137e97 100644 --- a/src/test/recovery/t/006_logical_decoding.pl +++ b/src/test/recovery/t/006_logical_decoding.pl @@ -7,7 +7,7 @@ use strict; use warnings; use PostgresNode; use TestLib; -use Test::More tests => 12; +use Test::More tests => 13; use Config; # Initialize master node @@ -27,12 +27,20 @@ $node_master->safe_psql('postgres', qq[SELECT pg_create_logical_replication_slot('test_slot', 'test_decoding');] ); +# Cover walsender error shutdown code +my ($result, $stdout, $stderr) = $node_master->psql('template1', + qq[START_REPLICATION SLOT test_slot LOGICAL 0/0], + replication => 'database'); +ok(($result == 3) and + ($stderr =~ 'replication slot "test_slot" was not created in this database'), + "Logical decoding correctly fails to start"); + $node_master->safe_psql('postgres', qq[INSERT INTO decoding_test(x,y) SELECT s, s::text FROM generate_series(1,10) s;] ); # Basic decoding works -my ($result) = $node_master->safe_psql('postgres', +$result = $node_master->safe_psql('postgres', qq[SELECT pg_logical_slot_get_changes('test_slot', NULL, NULL);]); is(scalar(my @foobar = split /^/m, $result), 12, 'Decoding produced 12 rows inc BEGIN/COMMIT'); --DocE+STaALJfprDB--