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 1rlM85-001rko-MV for pgsql-bugs@arkaria.postgresql.org; Sat, 16 Mar 2024 04:58:46 +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 1rlM83-00E7VO-1Z for pgsql-bugs@arkaria.postgresql.org; Sat, 16 Mar 2024 04:58:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rlM82-00E7VG-P8 for pgsql-bugs@lists.postgresql.org; Sat, 16 Mar 2024 04:58:43 +0000 Received: from mail-yb1-xb2e.google.com ([2607:f8b0:4864:20::b2e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rlM7z-004nPk-VT for pgsql-bugs@lists.postgresql.org; Sat, 16 Mar 2024 04:58:42 +0000 Received: by mail-yb1-xb2e.google.com with SMTP id 3f1490d57ef6-dcbcea9c261so2822284276.3 for ; Fri, 15 Mar 2024 21:58:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1710565118; x=1711169918; 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=opOFlVDThUQjLqNBW7MkL2Kn+BNU6gyfcDiIstzYIvM=; b=a0C559E3W7+o8AiN9TwZF6h3OU3o/5sM3AAh/X5sQMb7eRtVe0koQasvBJ1kMXVsEA OUoAjEDu7BjnqMaCYkbktWfqfYJgauDj6GEnsMSWNzMdlXKeNN8wqawocBdXwhZkV0cH MO8BzhZ7LCm19rVaQikEJYmeDqKbNJCwtzViE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710565118; x=1711169918; 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=opOFlVDThUQjLqNBW7MkL2Kn+BNU6gyfcDiIstzYIvM=; b=lwGidyTCfHayc99J4ZfqXLEAo9adcJrsSZqTi//atfana5qhiQ1YvunFb+UX4TVMMH Y3nw030r4F+l3WyvL9e+jxzSPNTuyuyonON4DL9kRm46D62NcEmABZ2h0AK9/Z5Kddqa kTZjqYz7JzcdQxDxslfFYTtFLEW6I6o8xdR47K+SBV0Qq5WpBo16yLfZRfVdX3Z+dOcg gif+HOOeqHR/u+Ssc+sTGaIBxnQatiLPMW3v1oYM+b61b8/kJUyfwEhSfCTzxzcbarVI roCtCx663blnkJRluaakvdnasD3MW0pgCoxUiJo78s7qj32rFtXH3O0qhQtHBgvw+pRf ROQw== X-Forwarded-Encrypted: i=1; AJvYcCWZpN6+CujNoU9FPMymW1ARDDzswUgLhvytu45j1XZX6MwAuesgwsEJAgLXiZtzG2Hnzd5nu5/Sduu09cq/OrMhusObKg9a3JW0BKSorXRJ X-Gm-Message-State: AOJu0Yz6USlfvEKBDbOGbGT2c2xyrMCyjZkLrxRkRWjevJhP5FBNwPEI 83Tn0xBhNwNpkfO8HCmviy8Lh6EB8q98UZYBXWJJ8hWmG2R+sHcn4LXjWkcNbA== X-Google-Smtp-Source: AGHT+IGEyBxE1djsKF8zMyPvncRnernc74gWqt+Y6kW2jhutmZawMoO1sEAf6/eMTrvs61Rn9/evSA== X-Received: by 2002:a25:acc2:0:b0:dd1:517b:571d with SMTP id x2-20020a25acc2000000b00dd1517b571dmr6674313ybd.16.1710565118036; Fri, 15 Mar 2024 21:58:38 -0700 (PDT) Received: from rfd.leadboat.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id 3-20020a251903000000b00dc6a0898efasm1012548ybz.15.2024.03.15.21.58.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Mar 2024 21:58:37 -0700 (PDT) Date: Fri, 15 Mar 2024 21:58:34 -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: <20240316045834.83@rfd.leadboat.com> References: <3225659.5fSG56mABF@aivenlaptop> <20240313165523.6a@rfd.leadboat.com> <5784272.DvuYhMxLoT@aivenlaptop> <20240316030339.03.nmisch@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240316030339.03.nmisch@google.com> 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 08:03:39PM -0700, Noah Misch wrote: > 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.) Forgot one more: - Your earlier version of the patch, with fewer lseek() but more disuse of FSM entries. > 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