Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rlKKr-001f4X-IZ for pgsql-bugs@arkaria.postgresql.org; Sat, 16 Mar 2024 03:03:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rlKKo-00Dh0g-TJ for pgsql-bugs@arkaria.postgresql.org; Sat, 16 Mar 2024 03:03:47 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rlKKo-00Dh0Y-D0 for pgsql-bugs@lists.postgresql.org; Sat, 16 Mar 2024 03:03:47 +0000 Received: from mail-yw1-x1130.google.com ([2607:f8b0:4864:20::1130]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rlKKk-004ko6-OQ for pgsql-bugs@lists.postgresql.org; Sat, 16 Mar 2024 03:03:45 +0000 Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-60fff981e2aso10212467b3.3 for ; Fri, 15 Mar 2024 20:03:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1710558222; x=1711163022; darn=lists.postgresql.org; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=mAReCyizji11xZda/Nx7LgIqXze7KFXD/gWNYqLtkS4=; b=S4QXenRwrBXBUNrLvqn0RrrxUqEjhR6fwQYrDejcvxpvoRPDugZN9xjdBAzIER2tIU F+iGP1oc2HeArAGZMX/iU+M+jPMcdoSGrlsKwYImk6zBcsCcEWrmQpSRg9ZNv1ADKgIA cEa5dW4PjvATKjXkKunARsd5JvP+dHWwmhdAA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710558222; x=1711163022; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mAReCyizji11xZda/Nx7LgIqXze7KFXD/gWNYqLtkS4=; b=DmrMZTHAB87PYk4Uo7PBeNqvaLvi+6B/qvl2jeQAyuehs5hk4J9CS7wmabAeYemE/6 LFARbG6ND+9Ht5IUlUYJO/onIWq2eph5vQgAllKXK0UzW+KrtquYMhP8N5VCnNRUwUBC rCie3hAwekwqpha1lDueLvfDIHnmr+5i8ddmeD1bzt8ldVEjkS0Q/DVKmE3Z2Ohzq7jh +pmRHGIaji/UZtElK6cHXVnxlGzePSrfriCMQZXEhDW51EwKqKokKFSgyuHumX65yfYa rBOpUV5ZQJxFURbkvDKkVG1RexTJXKQHUomT+7oxM5432J7hbCGuMfmXpLxu/G+/HaAt TXOw== X-Forwarded-Encrypted: i=1; AJvYcCVDIAHhoeNXCYtn7LWlQhUnsSs9qmudyeewRMN8qOsJoczMROWbjqbg4+QAumQyTGfFKZDTCbyTaLzeF4tZ60CxxbwroNtWe9CTWn7jaQl3 X-Gm-Message-State: AOJu0YyAerpgd5lVKUoCmzN4GroNZBFCcLvIXw2VU/1RzSPDFHwobNF2 30vlZ/CFNGJKoJ+5w9weT6kLI0dSPYW9F48ZRbwzeLM7urbuFi5PfNq+WBe1M5/vJViovpNXWDs = X-Google-Smtp-Source: AGHT+IFFVMJrnciDE1b6q0WEaB0v9GYhhQPsj8oBw4dNTMc7OAlQBVaBP8MH4KlONu4+B2fajavpCw== X-Received: by 2002:a81:6942:0:b0:60a:4a3e:a0c2 with SMTP id e63-20020a816942000000b0060a4a3ea0c2mr7243130ywc.22.1710558222584; Fri, 15 Mar 2024 20:03:42 -0700 (PDT) Received: from google.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id n128-20020a0dcb86000000b0060ccfedae49sm516723ywd.36.2024.03.15.20.03.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Mar 2024 20:03:42 -0700 (PDT) Date: Fri, 15 Mar 2024 20:03:39 -0700 From: Noah Misch To: Ronan Dunklau Cc: Michael Paquier , pgsql-bugs Subject: Re: FSM Corruption (was: Could not read block at end of the relation) Message-ID: <20240316030339.03.nmisch@google.com> References: <3225659.5fSG56mABF@aivenlaptop> <20240313165523.6a@rfd.leadboat.com> <5784272.DvuYhMxLoT@aivenlaptop> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5784272.DvuYhMxLoT@aivenlaptop> User-Agent: Mutt/2.2.12 (2023-09-09) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Mar 15, 2024 at 07:23:46AM +0100, Ronan Dunklau wrote: > Le mercredi 13 mars 2024, 17:55:23 CET Noah Misch a écrit : > > On Wed, Mar 13, 2024 at 10:37:21AM +0100, Ronan Dunklau wrote: > > > I'm a bit worried about triggering additional lseeks > > > when we in fact have other free pages in the map, that would pass the > > > test. I'm not sure how relevant it is given the way we search the FSM > > > with fp_next_slot though... > > > > That's a reasonable thing to worry about. We could do wrong by trying too > > hard to use an FSM slot, and we could do wrong by not trying hard enough. > > > > > To address that, I've given a bit of thought about enabling / disabling > > > the > > > auto-repair behaviour with a flag in GetPageWithFreeSpace to distinguish > > > the cases where we know we have a somewhat up-to-date value compared to > > > the case where we don't (as in, for heap, try without repair, then get an > > > uptodate value to try the last block, and if we need to look at the FSM > > > again then ask for it to be repaired) but it brings way too much > > > complexity and would need careful thought for each AM. > > > > > > So please find attached a patch with the change you propose. > > > > > > Do you have a link to the benchmark you mention though to evaluate the > > > patch against it ? > > > > Here is one from the thread that created commit 719c84c: > > https://www.postgresql.org/message-id/flat/CA%2BTgmob7xED4AhoqLspSOF0wCMYEom > > gHfuVdzNJnwWVoE_c60g%40mail.gmail.com > > > > There may be other benchmarks earlier in that thread. > > Thank you. I tried to run that benchmark, with 4 clients all copying 10M > pgbench_accounts row concurrently. With and without the patch, I ran the > benchmark 5 times, and took the average. Does "that benchmark" refer to "unlogged tables, 4 parallel copies", "logged tables, 4 parallel copies", or something else? > master: 15.05s > patched: 15.24s (+1.25%) > > If I remove the best and worst run for each of those, the difference falls at > +0.7%. To get some additional perspective on the benchmark, how hard would it be to run one or both of the following? Feel free to decline if difficult. - Make GetPageWithFreeSpace() just "return InvalidBlockNumber", then rerun the benchmark. This should be a lot slower. If not, the bottleneck is somewhere unexpected, and we'd need a different benchmark. - Get profiles with both master and patched. (lseek or freespace.c functions rising by 0.1%-1% would fit what we know.) Distinguishing a 1% change from a 0% change would need different techniques still. If we're genuinely slowing bulk loads by ~1% to account for the possibly of a flawed post-recovery FSM, that's sad, but I'm inclined to accept the loss. A persistent error in an innocent INSERT is unacceptable, and the alternatives we discussed upthread have their own substantial trouble. Other opinions? Thanks, nm