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 1jaDK6-0004u5-Rh for pgsql-hackers@arkaria.postgresql.org; Sun, 17 May 2020 07:02:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jaDK5-0005u2-6N for pgsql-hackers@arkaria.postgresql.org; Sun, 17 May 2020 07:02:57 +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 1jaDK4-0005tu-VA for pgsql-hackers@lists.postgresql.org; Sun, 17 May 2020 07:02:56 +0000 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jaDK2-0003AP-Ar for pgsql-hackers@lists.postgresql.org; Sun, 17 May 2020 07:02:56 +0000 Received: by mail-qt1-x844.google.com with SMTP id v4so5619383qte.3 for ; Sun, 17 May 2020 00:02:53 -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=4IT0RY8+AvQ9WfiZxWYnx+8DBZAMD4ZrDRKJGXzjSEw=; b=Adp8iwwSHHb1aGZDCPV07Wd3jLO6WvdDUst2hB5Mmb+6A4sFCTe8hEAsifBJ2Wl/aq 3Y4ZbPcsZvn5gR2a06sTSrQuw6KRLewf0zDH6yJRLzGCszO0P9aUwwP2pr2gMOET4yYB BxTfe+UkNO3PW4G/KAjmCVUF2kSYycdqn17lLIYULu0Ef/EgGMOHW7ybpBqc3iIypghh EpGDtvcT1yVfoqnroG6V0xMHdEz8VuXnTxRiQ9sHt8dqYwOuQzS83bvIMREWt2feQIOC sO72fwy1kYNDWJyziKEN62q4XaNg9Kwzi/V+Rwck94ebxjK5J0HtxG0/BhDm2pOjt1R+ dcqQ== 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=4IT0RY8+AvQ9WfiZxWYnx+8DBZAMD4ZrDRKJGXzjSEw=; b=MusVB0u/fLgaaeo1RZETOWRzxWuPurCY/HJ5dLzGULhJfUtSoCcZ0SDVqdj/obLptu GUobhkinf3SY50VqDdUNz9jbVUw+Z7ZPX6EtzxSGo4Qayx2+2IboRL8ftsFeUIVzqHDT +m8ua8rwhuwwPWiZVvUieNW8eTQur0F+W2YLBMY3lieOB9h8AbdacapXwCjMvwZVcc0f gvYJJs3AAty/j2cctLgoEQ4a+/jNYovvBVIsONSBpAty3TA0C/t/K6s4Zn/byQcww7YA i01dmknxLHY6e8vOrP0cWo1gkYJ3zl+Q/eKLs3RS5yrQxhchmVHjh8XPQXHS89B96SIi CK0w== X-Gm-Message-State: AOAM532bKhH19U9lVQOGR5DfFRm1j5EFllWPQY4RkhzkBUlWysCeNOwy 0+Zq05CoE4t18IynBZfbUOFFBw== X-Google-Smtp-Source: ABdhPJykO35QGkSVFCHgm6KMeNBXWca9O7CsHysl2FnfcS18kJ7ZZs8w/axfTTdsfCRWzbkj9KUj6w== X-Received: by 2002:aed:2565:: with SMTP id w34mr10927313qtc.54.1589698972078; Sun, 17 May 2020 00:02:52 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.95.18.252]) by smtp.gmail.com with ESMTPSA id i3sm5489548qkf.39.2020.05.17.00.02.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 May 2020 00:02:51 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 35AA830070F; Sun, 17 May 2020 03:02:49 -0400 (-04) Date: Sun, 17 May 2020 03:02:49 -0400 From: Alvaro Herrera To: Andres Freund Cc: Kyotaro Horiguchi , jgdr@dalibo.com, michael@paquier.xyz, sawada.mshk@gmail.com, peter.eisentraut@2ndquadrant.com, pgsql-hackers@lists.postgresql.org, thomas.munro@enterprisedb.com, sk@zsrv.org, michael.paquier@gmail.com Subject: Re: [HACKERS] Restricting maximum keep segments by repslots Message-ID: <20200517070249.GA21156@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200517032301.ddzwnqq7szkbdn7y@alap3.anarazel.de> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-May-16, Andres Freund wrote: > Hi, > > On 2020-05-16 22:51:50 -0400, Alvaro Herrera wrote: > > On 2020-May-16, Andres Freund wrote: > > > > > I, independent of this patch, added a few additional paths in which > > > checkpointer's latch is reset, and I found a few shutdowns in regression > > > tests to be extremely slow / timing out. The reason for that is that > > > the only check for interrupts is at the top of the loop. So if > > > checkpointer gets SIGUSR2 we don't see ShutdownRequestPending until we > > > decide to do a checkpoint for other reasons. > > > > Ah, yeah, this seems a genuine bug. > > > > > I also suspect that it could have harmful consequences to not do a > > > AbsorbSyncRequests() if something "ate" the set latch. > > > > I traced through this when looking over the previous fix, and given that > > checkpoint execution itself calls AbsorbSyncRequests frequently, I > > don't think this one qualifies as a bug. > > There's no AbsorbSyncRequests() after CheckPointBuffers(), I think. And > e.g. CheckPointTwoPhase() could take a while. Which then would mean that > we'd potentially not AbsorbSyncRequests() until checkpoint_timeout > causes us to wake up. Am I missing something? True. There's no delay like CheckpointWriteDelay in that code though, so the "a while" is much smaller. My understanding of these sync requests is that they're not for immediate processing anyway -- I mean it's okay for checkpointer to take a bit of time before syncing ... or am I mistaken? (If another sync request is queued and the queue hasn't been emptied, that would set the latch again, so it's not like this could fill the queue arbitrarily.) > > > One way to do that would be to WaitLatch() call to much earlier, and > > > only do a WaitLatch() if do_checkpoint is false. Roughly like in the > > > attached. > > > > Hm. I'd do "WaitLatch() / continue" in the "!do_checkpoint" block, and > > put the checpkoint code not in the else block; seems easier to read to > > me. > > Yea, that'd probably be better. I was also pondering if we shouldn't > just move the checkpoint code into, gasp, it's own function ;) That might work :-) -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services