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 1px2jZ-0008UJ-7X for pgsql-hackers@arkaria.postgresql.org; Thu, 11 May 2023 09:37:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1px2jY-0005YF-5o for pgsql-hackers@arkaria.postgresql.org; Thu, 11 May 2023 09:37:12 +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 1px2jX-0005Uh-0Y for pgsql-hackers@lists.postgresql.org; Thu, 11 May 2023 09:37:11 +0000 Received: from wnew4-smtp.messagingengine.com ([64.147.123.18]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1px2jT-001ion-KY for pgsql-hackers@postgresql.org; Thu, 11 May 2023 09:37:09 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id 4AE2F2B06016; Thu, 11 May 2023 05:37:03 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 11 May 2023 05:37:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1683797822; x=1683805022; bh=9kjpaxiSGGdPyhiVyITQw5mp+TFQ855MogU yNYKxQ94=; b=AK/sY71bcUT8/lmT/jeMusBRi5io4r9xMyMf9N49o/X7DRsG6ht b7RV1HSzkOS3rHxsDWjKAChGKuFEzSfCNkXSSowJ/Ss9/WJYOTD+PZxngcBzK7/t pjacc3CwgAKVo0+O6d25sHNr/GjU29Cu9IYBq12UHa4VF5cbu0ClW0B+hRdmFCRH tLu6MAYFO7ZLp68e6b3zTRk2/e69PPaaipgCaV9/Ac8cqffOTYo8dzw8JxFN9LAO VhC0ajoixyZZegKNntqZ/aNtbkZGQH+k8/nqOhMnwRmegh6+gkIc/Df1ddDJU2eE Fk1KwGPPgS7Sifgv6tbfRoqAZxtqk9Bwbag== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeegkedgudekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpefrvght vghrucfgihhsvghnthhrrghuthcuoehpvghtvghrrdgvihhsvghnthhrrghuthesvghnth gvrhhprhhishgvuggsrdgtohhmqeenucggtffrrghtthgvrhhnpeetgeejffdtleehtdfh heejteeikeffkedvteevkedttedtuddtieffiedvteekkeenucffohhmrghinhepfigvlh hlrdhhmhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhm pehpvghtvghrrdgvihhsvghnthhrrghuthesvghnthgvrhhprhhishgvuggsrdgtohhm X-ME-Proxy: Feedback-ID: i131946ab:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 11 May 2023 05:37:02 -0400 (EDT) Message-ID: Date: Thu, 11 May 2023 11:37:00 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: smgrzeroextend clarification Content-Language: en-US To: Andres Freund Cc: pgsql-hackers References: <22fed8ba-01c3-2008-a256-4ea912d68fab@enterprisedb.com> <20230510181049.ad5vw6kijqd2y274@awork3.anarazel.de> From: Peter Eisentraut In-Reply-To: <20230510181049.ad5vw6kijqd2y274@awork3.anarazel.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 10.05.23 20:10, Andres Freund wrote: >> Moreover, the text "except the relation can be extended by multiple blocks >> at once and the added blocks will be filled with zeroes" doesn't make much >> sense as a differentiation, because smgrextend() does that as well. > > Hm? smgrextend() writes a single block, and it's filled with the caller > provided buffer. But there is nothing that says that the block written by smgrextend() has to be the one right after the last existing block. You can give it any block number, and it will write there, and the blocks in between that are skipped over will effectively be filled with zeros. This is because of the way the POSIX file system APIs work. You can observe this by hacking it up like this: smgrextend(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, char *buffer, bool skipFsync) { + if (blocknum > smgrnblocks(reln, forknum) + 1) + elog(INFO, "XXX"); + smgrsw[reln->smgr_which].smgr_extend(reln, forknum, blocknum, buffer, skipFsync); Then you will get various test "failures" for hash indexes. If you hack it up even further and actively fill the skipped-over blocks with something other than zeros, you will get even more dramatic failures. So apparently, this behavior is actively being used. Maybe it was never meant that way and only works accidentally? Maybe hash indexes are broken?