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 1ifsZQ-0002wR-GR for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Dec 2019 21:33:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ifsZP-0006X1-85 for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Dec 2019 21:33:55 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1ifsZO-0006Wu-PU for pgsql-hackers@lists.postgresql.org; Fri, 13 Dec 2019 21:33:54 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ifsZK-0006cX-RK for pgsql-hackers@postgresql.org; Fri, 13 Dec 2019 21:33:53 +0000 Received: by mail-pl1-x643.google.com with SMTP id g6so1763262plp.7 for ; Fri, 13 Dec 2019 13:33:50 -0800 (PST) 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=5o50MAaXU9QSpbrrzJRhcE9q/NHGPKM5547ulkriExA=; b=QOOR0gDdr+vVtchZd2bQDIsSCIWk2ppnteNK2lvdchUC7YL3mQyXpHHM02/QV21t4Q DwNW6rxHYnAGJEPvox1HRd24sf3+Yo0emya8he3oyjF7xHJK20Lsw6XwuqFo4+bRWQYz dhGQUUHFeDxlHDeP26v1MKZylZDwN59PYhpsm/OMPdiE6l+BdWNSC7GobtDHmG4Dkz7T WP+RHjc2mJMKzI3ux/8QgCvw0d+IhMkvabR7JReEExiaaRXG+BkXFSuEGZKTHQ8mUJ/2 /dDkm6/0zIg11/v6eyPk/abb2bE1ti/YcpDfb2K+0ypkbR4RuKdEzf3wMRiY47EyzdP5 pkBw== 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=5o50MAaXU9QSpbrrzJRhcE9q/NHGPKM5547ulkriExA=; b=qN+7ccNuS4kC/G6BVKXa254OCOT/OG4HSB6PLsxrNxy1zuyxKR9UOH6RlMqAM1uvgi +/7GMn5bwmESN2RujkiYD1Rt2Jqu3OEezzf3mIkPJTdRMbrYN/HfHbHzkYVtenA8vRCU 2cVvQ91L4bVVVa7Umk64ScNdywH6OUc3Q8ITyZ1ry0iOCK+XL7NqHYPCJD1ln/VQoim0 1gBF6oeEBo9FJx4TpKMrWwp+x4oIv1ucT8D8UUXa2v7/yWtrKdXUNyGlrv6LIYAYzmyu Zr9fVBmvWidyN9L1G3R1+nsA03tratm1N5F6sSLeNxPKqagYBRxDvvBMJ+nAomfc3TkZ 7EHg== X-Gm-Message-State: APjAAAWsTc8G23aYYwuK/IyNQxPfYrm3I9WxbF/MuZFSJo5InWmajf1G 15Iln4Nf6hku5MyJhtA80FQ0gg== X-Google-Smtp-Source: APXvYqx5vSKSBISLQKtb4UXutQFwwqW79mHiPh5GKNIwbS1vxHRbdCtc/nY6JwAqYEUf4nmA9e3X1g== X-Received: by 2002:a17:90a:8986:: with SMTP id v6mr1754793pjn.63.1576272828478; Fri, 13 Dec 2019 13:33:48 -0800 (PST) Received: from nimloth.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id z26sm11597971pgu.80.2019.12.13.13.33.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2019 13:33:47 -0800 (PST) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 60B5F30093E; Fri, 13 Dec 2019 18:33:44 -0300 (-03) Date: Fri, 13 Dec 2019 18:33:44 -0300 From: Alvaro Herrera To: Kyotaro Horiguchi Cc: bossartn@amazon.com, pgsql-hackers@postgresql.org Subject: Re: archive status ".ready" files may be created too early Message-ID: <20191213213344.GA14295@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20191213.130722.1074070497227350163.horikyota.ntt@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-Dec-13, Kyotaro Horiguchi wrote: > At Thu, 12 Dec 2019 22:50:20 +0000, "Bossart, Nathan" wrote in > > The crux of the issue seems to be that XLogWrite() does not wait for > > the entire record to be written to disk before creating the ".ready" > > file. Instead, it just waits for the last page of the segment to be > > written before notifying the archiver. If PostgreSQL crashes before > > it is able to write the rest of the record, it will end up reusing the > > ".ready" segment at the end of crash recovery. In the meantime, the > > archiver process may have already processed the old version of the > > segment. > > Year, that can happen if the server restarted after the crash. ... which is the normal way to run things, no? > > servers after the primary server has crashed because it ran out of > > disk space. > > In the first place, it's quite bad to set restart_after_crash to on, > or just restart crashed master in replication set. Why is it bad? It's the default value. > The standby can be incosistent at the time of master crash, so it > should be fixed using pg_rewind or should be recreated from a base > backup. Surely the master will just come up and replay its WAL, and there should be no inconsistency. You seem to be thinking that a standby is promoted immediately on crash of the master, but this is not a given. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services