Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d6RzQ-0007YE-Mo for pgsql-hackers@arkaria.postgresql.org; Fri, 05 May 2017 01:25:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d6RzQ-00052c-2J for pgsql-hackers@arkaria.postgresql.org; Fri, 05 May 2017 01:25:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d6RzP-00050Z-9v for pgsql-hackers@postgresql.org; Fri, 05 May 2017 01:24:59 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d6RzG-0007sH-V5 for pgsql-hackers@postgresql.org; Fri, 05 May 2017 01:24:58 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 6016620906; Thu, 4 May 2017 21:24:49 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Thu, 04 May 2017 21:24:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=fm1; bh=9cJ5qVqTeq1S7wzEVJ QNzzkBnZ9Az8NmphBAOWncxOo=; b=Rlea7xMynDuQpUOAh/SgOE36fex/DtuWFp BouNpEX1VxlJpIMfw1RouA2BAPcAOIpGbZHWVlV6v5FnzVcbxO/5qFAwHju5kAHe UF7YJwbvT5iPmAMcq/OBLG0Er3KFQgT8k3Q6lq6sR3LFlwZU4A5GrWbtPwI6baQ0 mMHkNrL/X7/oGZUUZo4Mvy0QLKxdoorjFaY+GE3RFc/P747PtaW2bdD1FLGsydBz bnEoP1BbvqL5Xiu0FWTpDxckshf7DLKy6KkxfpYxS6tq/Qw4HCeF4PFXsXs4WlxA qqTPAsohGBJfebdu3yxr+rmPSut4IZ2uGbvAjBAommjMsbrJ1eaA== X-ME-Sender: X-Sasl-enc: TEAxwSSc+Q+wAvfHaRsJ9BGZ1bkPYdthNSXu9AB3CQwa 1493947489 Received: from intern.anarazel.de (unknown [208.72.138.107]) by mail.messagingengine.com (Postfix) with ESMTPA id 2053A7E266; Thu, 4 May 2017 21:24:49 -0400 (EDT) Date: Thu, 4 May 2017 18:24:47 -0700 From: Andres Freund To: pgsql-hackers@postgresql.org, Michael Paquier Subject: Change GetLastImportantRecPtr's definition? (wasSkip checkpoints, archiving on idle systems.) Message-ID: <20170505012447.wsrympaxnfis6ojt@alap3.anarazel.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Pg-Spam-Score: -2.6 (--) 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 Hi, On 2016-12-22 19:33:30 +0000, Andres Freund wrote: > Skip checkpoints, archiving on idle systems. As part of an independent bugfix I noticed that Michael & I appear to have introduced an off-by-one here. A few locations do comparisons like: /* * Only log if enough time has passed and interesting records have * been inserted since the last snapshot. */ if (now >= timeout && last_snapshot_lsn < GetLastImportantRecPtr()) { last_snapshot_lsn = LogStandbySnapshot(); ... which looks reasonable on its face. But LogStandbySnapshot (via XLogInsert()) * Returns XLOG pointer to end of record (beginning of next record). * This can be used as LSN for data pages affected by the logged action. * (LSN is the XLOG point up to which the XLOG must be flushed to disk * before the data page can be written out. This implements the basic * WAL rule "write the log before the data".) and GetLastImportantRecPtr * GetLastImportantRecPtr -- Returns the LSN of the last important record * inserted. All records not explicitly marked as unimportant are considered * important. which means that we'll e.g. not notice if there's exactly a *single* WAL record since the last logged snapshot (and likely similar in the other users of GetLastImportantRecPtr()), because XLogInsert() will return where the next record will most of the time be inserted, and GetLastImportantRecPtr() returns the beginning of said record. This is trivially fixable by replacing < with <=. But I wonder if the better fix would be to redefine GetLastImportantRecPtr() to point to the end of the record, too? I don't quite see any upcoming user that'd need the beginning, and this is a bit failure prone for likely users. - Andres -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers