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 1rgvYB-008gmd-OG for pgsql-bugs@arkaria.postgresql.org; Sun, 03 Mar 2024 23:47:24 +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 1rgvYA-002iGH-87 for pgsql-bugs@arkaria.postgresql.org; Sun, 03 Mar 2024 23:47:22 +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 1rgvY9-002iFN-Oc for pgsql-bugs@lists.postgresql.org; Sun, 03 Mar 2024 23:47:22 +0000 Received: from mail-yw1-x1131.google.com ([2607:f8b0:4864:20::1131]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rgvY6-002huz-BC for pgsql-bugs@lists.postgresql.org; Sun, 03 Mar 2024 23:47:20 +0000 Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-608c40666e0so32098287b3.2 for ; Sun, 03 Mar 2024 15:47:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1709509638; x=1710114438; darn=lists.postgresql.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=U2hZEs5uDCVp7XqAKprOtsrVpigLu4IJlWy1m1CnqTw=; b=P0eYr2Hi7JhX/S6BcyJhpsnHqnJNXut+unbAM78Fnkf/xqR6q7Ko4offdNseoh/Bk8 sIwWZ0savZ997FerwPTlk0GJuiEOKRTYlK7LDxnWUFn9VovFg2ivHwReMGDE86G5R04l 7803W2NsMXNvPaES6bWLFdd0GGWtb+VFst38g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709509638; x=1710114438; h=user-agent:in-reply-to: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=U2hZEs5uDCVp7XqAKprOtsrVpigLu4IJlWy1m1CnqTw=; b=J6lSmeL5E13IJNH7vO1ovXIeIZR+4AxzZBLwlNAoeaBcBcdH8fZim0TsorjIHKXEqf X8cvZl9twYmo4n1yUj7sY2MY1g4bSyR619KHXGpAugb1CTyky8ocEkdWN2SI5AnABwzD ahVHx9Iud5yTPY/snHbb12JWvqx7eFd1pvjjeKq05GANHPo6kDa98Wixm2FVSnYDN+Jx m9sJbSdcWGb25GNT9hKYncWLUY4l7kZnyFDnugAu4SaBvNOajRS+/7Bv46OeYyXaRBO2 QOGZADe56ApT9yt/fjROvWFC21qq/blve3RfUVJ6X+S5wbMbX1lSlEeMxV0sMThdZY53 NgQw== X-Gm-Message-State: AOJu0YwoabcuCMMx0XtAvgucVaARDCHlR5r6Vfxz73hf9VMWWbEaTZ8J P7iYkwpdzePBxYCn8L/qcJwa2XR7SdosVdZXmCRP2dVLqky9ejHt5iC4sn35kg== X-Google-Smtp-Source: AGHT+IGapo4FR4GbWme1DoavTTbyOctvj+abYEdGc76L6evyq1I5g3rarWr0mykGx/oaaRqjChS+IQ== X-Received: by 2002:a05:690c:fd3:b0:608:ff01:5128 with SMTP id dg19-20020a05690c0fd300b00608ff015128mr6360438ywb.15.1709509638589; Sun, 03 Mar 2024 15:47:18 -0800 (PST) Received: from rfd.leadboat.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id g4-20020a81ae44000000b006077d0a9f21sm2315884ywk.93.2024.03.03.15.47.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Mar 2024 15:47:17 -0800 (PST) Date: Sun, 3 Mar 2024 15:47:15 -0800 From: Noah Misch To: Ronan Dunklau Cc: pgsql-bugs Subject: Re: FSM Corruption (was: Could not read block at end of the relation) Message-ID: <20240303234715.4d@rfd.leadboat.com> References: <1878547.tdWV9SEqCh@aivenlaptop> <1958255.PYKUYFuaPT@aivenlaptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1958255.PYKUYFuaPT@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 Tue, Feb 27, 2024 at 11:34:14AM +0100, Ronan Dunklau wrote: > - happens during heavy system load > - lots of concurrent writes happening on a table > - often (but haven't been able to confirm it is necessary), a vacuum is running > on the table at the same time the error is triggered > > Then, several backends get the same error at once "ERROR: could not read > block XXXX in file "base/XXXX/XXXX": read only 0 of 8192 bytes", with different What are some of the specific block numbers reported? > has anybody witnessed something similar ? https://postgr.es/m/flat/CA%2BhUKGK%2B5DOmLaBp3Z7C4S-Yv6yoROvr1UncjH2S1ZbPT8D%2BZg%40mail.gmail.com reminded me of this. Did you upgrade your OS recently? On Fri, Mar 01, 2024 at 09:56:51AM +0100, Ronan Dunklau wrote: > I think I may have missed something on my first look. On other affected > clusters, the FSM is definitely corrupted. So it looks like we have an FSM > corruption bug on our hands. What corruption signs did you observe in the FSM? Since FSM is intentionally not WAL-logged, corruption is normal, but corruption causing errors is not normal. That said, if any crash leaves a state that the freespace/README "self-correcting measures" don't detect, errors may happen. Did the clusters crash recently? > The occurence of this bug happening makes it hard to reproduce, but it's > definitely frequent enough we witnessed it on a dozen PostgreSQL clusters. You could do "ALTER TABLE x SET (vacuum_truncate = off);" and see if the problem stops happening. That would corroborate the VACUUM theory. Can you use backtrace_functions to get a stack track? > In our case, we need to repair the FSM. The instructions on the wiki do work, > but maybe we should add something like the attached patch (modeled after the > same feature in pg_visibility) to make it possible to repair the FSM > corruption online. What do you think about it ? That's reasonable in concept.