Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iZMFx-0006eR-07 for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Nov 2019 21:50:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iZMFv-0005kl-BS for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Nov 2019 21:50:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iZMFu-0005ke-Nl for pgsql-hackers@lists.postgresql.org; Mon, 25 Nov 2019 21:50:51 +0000 Received: from mail-io1-xd42.google.com ([2607:f8b0:4864:20::d42]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iZMFs-0002gr-1D for pgsql-hackers@postgresql.org; Mon, 25 Nov 2019 21:50:49 +0000 Received: by mail-io1-xd42.google.com with SMTP id k1so18065603ioj.6 for ; Mon, 25 Nov 2019 13:50:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=RRXzNzfwfk503auWGZIoYrPXb4h2nmkoxvhW8QEicIg=; b=f0sRsGYb3psF/lfHvv/JeuIOBo54UD08jUAizb7G7tRm/wSyPjEe9P2ob+rfQr2EMT q8+7IUyTl22pmgLokZMwXt1vaHgHnMTRleiX7a0HNLCZjDAlKInDNqtqL2G+DPK0ytW/ dr1LsEfbYohahZc0+zclVz1hH1RH8ZAflCNH4= 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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=RRXzNzfwfk503auWGZIoYrPXb4h2nmkoxvhW8QEicIg=; b=DvDeulMrlRhJiXRmrLk5GmhWuIbJP3Ktggm/+KhlA9KouPi1EFQTK9iFczZ1YTDSCw 4i1rptIZ6YhRgY+ksfdufEx2z4DW6viX0hfsavKTqEbdZJtcuvclinkNRwZ9X+yGK2O+ rsplpcCaxVRYQhuJGGyDV5ejl95XEG37/dAgvT7+6vYua2iREqCI8SfOFhh8YNjQOUfM ncyzwLi/43fFnJW1wqGfUd/dXgiSEGtszEuFGDEEcuH0AqpKBljYY3PIbqVNlh0N5LDy emK8XurhZkxDCJeA8MWcB7IE509d84cMCsp4zm0QG1HcMEKt6UkLhOps6sjQbXFZgQGX yaGg== X-Gm-Message-State: APjAAAXhw2TZytw/cw4n2GR06ldo/5hox6+2lncS2+/jOr6igvGGnz80 jq9QnSJ0MWhDhdxqAeFGgjiTUw== X-Google-Smtp-Source: APXvYqyz4cVqe3EL4czQ/8/3eLCEE8xvj6vCmMbtMytha8myjHz24bA+fvdb+o14b9yxq9V4s1DHAQ== X-Received: by 2002:a05:6638:9:: with SMTP id z9mr28765986jao.35.1574718647114; Mon, 25 Nov 2019 13:50:47 -0800 (PST) Received: from gust.leadboat.com ([172.243.182.239]) by smtp.gmail.com with ESMTPSA id k6sm2147773iom.52.2019.11.25.13.50.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Nov 2019 13:50:40 -0800 (PST) Date: Mon, 25 Nov 2019 16:50:25 -0500 From: Noah Misch To: Robert Haas Cc: Kyotaro Horiguchi , "pgsql-hackers@postgresql.org" , Dmitry Dolgov <9erthalion6@gmail.com>, Andrew Dunstan , hlinnaka , Michael Paquier Subject: Re: [HACKERS] WAL logging problem in 9.4.3? Message-ID: <20191125215025.GA53580@gust.leadboat.com> References: <20191105225335.GA395764@rfd.leadboat.com> <20191118045434.GA1173436@rfd.leadboat.com> <20191121.160107.1405593316918593372.horikyota.ntt@gmail.com> <20191123212136.GA41522@gust.leadboat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Nov 25, 2019 at 03:58:14PM -0500, Robert Haas wrote: > On Sat, Nov 23, 2019 at 4:21 PM Noah Misch wrote: > > I noticed an additional defect: > > > > BEGIN; > > CREATE TABLE t (c) AS SELECT 1; > > CHECKPOINT; -- write and fsync the table's one page > > TRUNCATE t; -- no WAL > > COMMIT; -- no FPI, just the commit record > > > > If we crash after the COMMIT and before the next fsync or OS-elected sync of > > the table's file, the table will stay on disk with its pre-TRUNCATE content. > > Shouldn't the TRUNCATE be triggering an fsync() to happen before > COMMIT is permitted to complete? With wal_skip_threshold=0, you do get an fsync(). The patch tries to avoid at-commit fsync of small files by WAL-logging file contents instead. However, the patch doesn't WAL-log enough to handle files that decreased in size. > You'd have the same problem if the > TRUNCATE were replaced by INSERT, unless fsync() happens in that case. I think an insert would be fine. You'd get an FPI record for the relation's one page, which fully reproduces the relation.