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 1neAIT-0005Ld-VP for pgsql-hackers@arkaria.postgresql.org; Tue, 12 Apr 2022 06:46:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1neAIS-0002CN-I4 for pgsql-hackers@arkaria.postgresql.org; Tue, 12 Apr 2022 06:46:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1neAIS-0002CE-7E for pgsql-hackers@lists.postgresql.org; Tue, 12 Apr 2022 06:46:40 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1neAIP-0001oF-5n for pgsql-hackers@postgresql.org; Tue, 12 Apr 2022 06:46:39 +0000 Received: by mail-pl1-x62c.google.com with SMTP id j8so15933080pll.11 for ; Mon, 11 Apr 2022 23:46:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:message-id:to:cc:subject:from:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=PMs85igweV2NnxBaDoWp+N3S988ebQoJ+pTcvKWS7Kw=; b=ROxoO9JYsGYPQsDL/ptvfFLbH2YGbLa87e8Nm6MG9Oo8wX/+noUoUdaPFOtJ6/Jf7+ 0gcKoCWPzajkAmW4pxIyKdEj8+qYn2m4rr2b/IpgE5MxgIZTOV2iVjXITGdNIUeF/kCy GIposayf6nukPFEVXSTqaPUNKpTgtyUKo/U7KMCOCefUHYc/NfsdTGbRRyESPZ5zTlZW tos5YQpQL8OFc2GrSnJiVV9m7fS9Yq9y6ekRNCeUjosG46PAXo7GEocTxfWjK0xsYUor LEG25T9zqnKDdisDW553rgkRwr+js4Hq23tQHA1vlhy5IOOGoRTZ65PnBJec2BSeunvy 1BXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:to:cc:subject:from:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=PMs85igweV2NnxBaDoWp+N3S988ebQoJ+pTcvKWS7Kw=; b=8Gn8N7j1BjqGKGqjcPstyjUuvomxkKtDuM2ndxbbWLkUPkBwPPqAdgx+/R91PIbjDz s6Yb6RlsKtZwx757ia2ja2F/KducTf+UAR217v+uIaQTW/lStEX4BOQ1gh8kIC1BG1td qjVxVnUHYUdsqq584C6IR2e9Is0iDYpPSF584wxM+gw/A+wgH7sIEZ70TgURMP/ZMCPV 0p/ruaUD0vDbQNErUvDT9PNLAeespp9DVXcoTYgakkNmjjv1wyGyRwoHcppofVTxOfen OVB/+BMo31iCnEgCc+Ecx6Sw9ZCMwtmnQKjBAihx5ysqZXXZguynVX31U9J3TqkZRHZ+ KklA== X-Gm-Message-State: AOAM5303OQFrsnM7t0sgz/laXs/HSo3XZ7dE1ObPdCgmXDSj/S5dplwR uHwmWew1St7s6gP1IRWmiOc= X-Google-Smtp-Source: ABdhPJyUD1z++IXNUl9oDv8qgx77AS8rIQx5ZhT9ZHePEUDn1ldxFwV27s/LPjmr6S83rM+Kz+SRig== X-Received: by 2002:a17:902:9b87:b0:156:bf3e:9ab5 with SMTP id y7-20020a1709029b8700b00156bf3e9ab5mr36096073plp.119.1649745996011; Mon, 11 Apr 2022 23:46:36 -0700 (PDT) Received: from localhost (KD036014041111.ppp-bb.dion.ne.jp. [36.14.41.111]) by smtp.gmail.com with ESMTPSA id c9-20020a63a409000000b0039912d50806sm1646993pgf.87.2022.04.11.23.46.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 11 Apr 2022 23:46:35 -0700 (PDT) Date: Tue, 12 Apr 2022 15:46:31 +0900 (JST) Message-Id: <20220412.154631.417529439388886590.horikyota.ntt@gmail.com> To: nathandbossart@gmail.com Cc: tgl@sss.pgh.pa.us, robertmhaas@gmail.com, pgsql-hackers@postgresql.org Subject: Re: avoid multiple hard links to same WAL file after a crash From: Kyotaro Horiguchi In-Reply-To: <20220411165257.GB1915258@nathanxps13> References: <289699.1649694527@sss.pgh.pa.us> <20220411165257.GB1915258@nathanxps13> User-Agent: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk At Mon, 11 Apr 2022 09:52:57 -0700, Nathan Bossart wrote in > On Mon, Apr 11, 2022 at 12:28:47PM -0400, Tom Lane wrote: > > Robert Haas writes: > >> On Mon, Apr 11, 2022 at 5:12 AM Kyotaro Horiguchi > >> wrote: > >>> If this diagnosis is correct, the comment is proved to be paranoid. > > > >> It's sometimes difficult to understand what problems really old code > >> comments are worrying about. For example, could they have been > >> worrying about bugs in the code? Could they have been worrying about > >> manual interference with the pg_wal directory? It's hard to know. > > > > "git blame" can be helpful here, if you trace back to when the comment > > was written and then try to find the associated mailing-list discussion. > > (That leap can be difficult for commits pre-dating our current > > convention of including links in the commit message, but it's usually > > not *that* hard to locate contemporaneous discussion.) > > I traced this back a while ago. I believe the link() was first added in > November 2000 as part of f0e37a8. This even predates WAL recycling, which > was added in July 2001 as part of 7d4d5c0. f0e37a8 lacks discussion.. It introduced the CHECKPOINT command from somwhere out of the ML.. This patch changed XLogFileInit to supportusing existent files so that XLogWrite can use the new segment provided by checkpoint and still allow XLogWrite to create a new segment by itself. Just before the commit, calls to XLogFileInit were protected (or serialized) by logwr_lck. At the commit calls to the same function were still serialized by ControlFileLockId. I *guess* that Vadim faced/noticed a race condition when he added checkpoint. Thus introduced the link+remove protocol but finally it became useless by moving the call to XLogFileInit within ControlFileLockId section. But, of course, all of story is mere a guess. regards. -- Kyotaro Horiguchi NTT Open Source Software Center