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 1q8ycl-0002Hs-6j for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Jun 2023 07:39:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q8ycj-0005a5-Qg for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Jun 2023 07:39:29 +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 1q8ycj-0005Zw-Fe for pgsql-hackers@lists.postgresql.org; Tue, 13 Jun 2023 07:39:29 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1q8ycg-0025QX-OA for pgsql-hackers@postgresql.org; Tue, 13 Jun 2023 07:39:28 +0000 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-652a6bf4e6aso4107856b3a.2 for ; Tue, 13 Jun 2023 00:39:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686641964; x=1689233964; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:from:subject:cc:to:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=5ECsWGPNBIEXBqwjgC04VSMPi7wOJ7xoK0obNzEgeRU=; b=bh1Nu33KJa2/zo+sj7aD+mLedivPCqC9wTTRIPHlZqrX0cttr3S+yyd5W3v1wEPrbp XO/5mO/HtKYRPRHlSJnbbXE7AkXGYt4yvXBfvivYaPw9ODFpSnvQrHyRIJ2qQ2ncErsl mThyJnXHKKZWZusPwz1h4VE4Gnk6HXJdmXPRqkInOf6V89kyRFqDlefSviC3WKfwtbdj jsz7YvIrYNcuvQeXm9fpGDrHf7UPWq9Aobf/fJbYv6ojh36mAJwmeHWR2FzJo79biwGX 3wQj3o7ju2wkYMX2cQw3PtVKzn+RNNgOWXL4cfQRh4T2nefN4+rf/z3Dgj9+CD5Vm7X8 ewCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686641964; x=1689233964; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:from:subject:cc:to:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=5ECsWGPNBIEXBqwjgC04VSMPi7wOJ7xoK0obNzEgeRU=; b=DeTwG/T/dRrgp5YC69Y/FUWbpemjRnLMg7wkw9Fhj9xItL7EOzfBAP8ussRHP8oKkq TGL+DyO0Is3yv2JNwVAPcI+/uLfylLWKdHAjIRGSOnm28bbgQ57Y7H4IiPXXMIry0jzn zCpe71OL/kpNs4ioWopYyFTCStK7Idjutnv5WsQ2F+gDtfVvxvjU8mb/Bzw/12JN32YJ CLRJYkqM7UQ6yCeh4OTICSYN+TWiwc3VJX4ogY2ZCcPeHGu9OhtA4m9uiT43S35VWR/V 6WMdZc4tgO3aEmji7Qt3AmkQWxOSC1mof+uy0ydJH+jCYJE23F49SlO4t04cNlCOzKTi 2d3Q== X-Gm-Message-State: AC+VfDzybIDJHm7CRoDQcbLsTwvdsHUsUL88pl7Yz0Zyo/XF7qzpT8I5 nLUIWdfybyHGolfYTUuNLrU= X-Google-Smtp-Source: ACHHUZ47fPOkWfo+4w6SxsingQNgjpH9Ge0gOeWxNf0Nh7iKmovdemkxomexcRhzcQej1vkqn5qSiw== X-Received: by 2002:a05:6a20:3d87:b0:119:94f4:c62e with SMTP id s7-20020a056a203d8700b0011994f4c62emr11815204pzi.19.1686641964416; Tue, 13 Jun 2023 00:39:24 -0700 (PDT) Received: from localhost (KD036014041111.ppp-bb.dion.ne.jp. [36.14.41.111]) by smtp.gmail.com with ESMTPSA id d8-20020a170902cec800b001b3d756a6f4sm2694939plg.13.2023.06.13.00.39.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 00:39:23 -0700 (PDT) Date: Tue, 13 Jun 2023 16:39:21 +0900 (JST) Message-Id: <20230613.163921.1246444645573084901.horikyota.ntt@gmail.com> To: michael@paquier.xyz Cc: gurjeet@singh.im, ranier.vf@gmail.com, guofenglinux@gmail.com, pgsql-hackers@postgresql.org Subject: Re: Avoid unncessary always true test (src/backend/storage/buffer/bufmgr.c) From: Kyotaro Horiguchi In-Reply-To: References: User-Agent: Mew version 6.8 on Emacs 27.2 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 Tue, 13 Jun 2023 15:11:26 +0900, Michael Paquier wrote in > On Mon, Jun 12, 2023 at 10:51:24PM -0700, Gurjeet Singh wrote: > > To me, it looks like these checks are a result of code being > > copy-pasted from somewhere else, where this check might have been > > necessary. The checks are sure not necessary at these spots. > > I am not completely sure based on my read of the code, but isn't this > check needed to avoid some kind of race condition with a concurrent > backend may have worked on the relation when attempting to get the > lock? Gurjeet has mentioned that eb.rel cannot be modified by another process since the value or memory is in the local stack, and I believe he's correct. If the pointed Relation had been blown out, eb.rel would be left dangling, not nullified. However, I don't believe this situation happens (or it shouldn't happen) as the entire relation should already be locked. regards. -- Kyotaro Horiguchi NTT Open Source Software Center