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 1jOAXa-0007bq-KH for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Apr 2020 01:39:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jOAXZ-0001Jn-Ch for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Apr 2020 01:39:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jOAXY-0001Ii-Rz for pgsql-hackers@lists.postgresql.org; Tue, 14 Apr 2020 01:39:05 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jOAXQ-0007M8-76 for pgsql-hackers@postgresql.org; Tue, 14 Apr 2020 01:39:03 +0000 Received: by mail-pg1-x541.google.com with SMTP id i3so1282032pgk.1 for ; Mon, 13 Apr 2020 18:38:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=yXVafqEzZGjXRw1K5KEsy/iVa/0nTQGhlqoZv+yjk6I=; b=At8kjCPA+0Yxqn1HhCc4fD2fg5Lg7BUdjv8PVQUYhohMD9BlXpAdNRanbY/EIwPOdd N0rr1IA/kHT2e+kgbOn+T/wRX+FqzISosbC1fhmqR//hMLMkRNPdIq4ZPN1w1pyGkhXX BS4rOHRgbBt9hsgvQA0uPlq6KYgwXY9UfuXik= 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:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=yXVafqEzZGjXRw1K5KEsy/iVa/0nTQGhlqoZv+yjk6I=; b=W07dA0ifXX63uiGAFE8bevp5V4azVsbMxtdrfJ/NA+24EdCFEsdbDBqTtyMSPPdThs G9kHQloRZmVrwZmxaChQK/VObioG1cqYD2URi7AgpvMnLD5SLCZieNiIVStzE1CWfRq0 2r8d6JBERLHD40utatpDm5Ypw9VBJi+i6M9P1FDsF8nGF8hJ6AmdXIcM3iztDb08JFP0 2v4Ejuz+zBGSt3pHf5IKgCJaRq+QjkcmwvQ6UZW9gykjRBTRs7HMpjbzWWllmQepwwrD 7Nueltfzjzs814thMj8HI0Gr26165owA8LmOI+UjQfqsTassYytSFo7s6PeLmSIZVJ7K i3NA== X-Gm-Message-State: AGi0PuYpuQfw1iPvu1pIQoSGzDBkPafqWkVKuu+r+KCldpSlgyEN37Yn 1H63LlrqCGS0zQx3sEhSp7MZ6t0LiPs= X-Google-Smtp-Source: APiQypK+Yhv7uMQvtzij7Fuw5PjglKH7TjrI+eA83o+oxUKFo+N911ZF4iKpy04yu0/JS7e+d1E6Mw== X-Received: by 2002:a05:6a00:46:: with SMTP id i6mr20738272pfk.123.1586828332665; Mon, 13 Apr 2020 18:38:52 -0700 (PDT) Received: from rfd.leadboat.com (108-233-125-46.lightspeed.sntcca.sbcglobal.net. [108.233.125.46]) by smtp.gmail.com with ESMTPSA id l1sm9021462pga.69.2020.04.13.18.38.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Apr 2020 18:38:50 -0700 (PDT) Date: Mon, 13 Apr 2020 18:38:49 -0700 From: Noah Misch To: pgsql-hackers@postgresql.org Subject: Re: 001_rep_changes.pl stalls Message-ID: <20200414013849.GA886648@rfd.leadboat.com> References: <20200406063649.GA3738151@rfd.leadboat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200406063649.GA3738151@rfd.leadboat.com> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sun, Apr 05, 2020 at 11:36:49PM -0700, Noah Misch wrote: > Executive summary: the "MyWalSnd->write < sentPtr" in WalSndWaitForWal() is > important for promptly updating pg_stat_replication. When caught up, we > should impose that logic before every sleep. The one-line fix is to sleep in > WalSndLoop() only when pq_is_send_pending(), not when caught up. This seems to have made the following race condition easier to hit: https://www.postgresql.org/message-id/flat/20200206074552.GB3326097%40rfd.leadboat.com https://www.postgresql.org/message-id/flat/21519.1585272409%40sss.pgh.pa.us Now it happened eight times in three days, all on BSD machines: https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=curculio&dt=2020-04-11%2018%3A30%3A21 https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=sidewinder&dt=2020-04-11%2018%3A45%3A39 https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=curculio&dt=2020-04-11%2020%3A30%3A26 https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=sidewinder&dt=2020-04-11%2021%3A45%3A48 https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=sidewinder&dt=2020-04-13%2010%3A45%3A35 https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=conchuela&dt=2020-04-13%2016%3A00%3A18 https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=sidewinder&dt=2020-04-13%2018%3A45%3A34 https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=sidewinder&dt=2020-04-13%2023%3A45%3A22 While I don't think that indicates anything wrong with the fix for $SUBJECT, creating more buildfarm noise is itself bad. I am inclined to revert the fix after a week. Not immediately, in case it uncovers lower-probability bugs. I'd then re-commit it after one of those threads fixes the other bug. Would anyone like to argue for a revert earlier, later, or not at all? There was a novel buildfarm failure, in 010_logical_decoding_timelines.pl: https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=hoverfly&dt=2020-04-13%2008%3A35%3A05 https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=hoverfly&dt=2020-04-13%2017%3A15%3A01 Most-relevant lines of the test script: $node_master->safe_psql('postgres', "INSERT INTO decoding(blah) VALUES ('afterbb');"); $node_master->safe_psql('postgres', 'CHECKPOINT'); $node_master->stop('immediate'); The failure suggested the INSERT was not replicated before the immediate stop. I can reproduce that consistently, before or after the fix for $SUBJECT, by modifying walsender to delay 0.2s before sending WAL: --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -65,2 +65,3 @@ #include "libpq/pqformat.h" +#include "libpq/pqsignal.h" #include "miscadmin.h" @@ -2781,2 +2782,5 @@ retry: + PG_SETMASK(&BlockSig); + pg_usleep(200 * 1000); + PG_SETMASK(&UnBlockSig); pq_putmessage_noblock('d', output_message.data, output_message.len); I will shortly push a fix adding a wait_for_catchup to the test. I don't know if/how fixing $SUBJECT made this 010_logical_decoding_timelines.pl race condition easier to hit.