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 1qvUCj-005URp-T0 for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Oct 2023 03:05:09 +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 1qvUCi-00Fs3e-J7 for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Oct 2023 03:05:08 +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 1qvUCi-00Fs3I-2a for pgsql-hackers@lists.postgresql.org; Wed, 25 Oct 2023 03:05:08 +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 1qvUCd-002Ags-P5 for pgsql-hackers@postgresql.org; Wed, 25 Oct 2023 03:05:06 +0000 Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-5a84204e7aeso50115327b3.0 for ; Tue, 24 Oct 2023 20:05:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1698203102; x=1698807902; darn=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=mjdx+X6kSsMpIfxHdDdiHl+XAGtwL5u54eHOXL3lpAg=; b=HA9F3Fg8wEf2d603B8hTdn2UWbsJvKANWOIY/oRU46v3/YT9FAUE2owSdGny1R6MBK mAAmIqyy/U+R1bxen0nSsoS4uzerJPX9X/PyozMtB+oI0L6rt118nmFgqBHnLyXt9NsY sk9kvrptRseuAEcNtBmWdBuaAJZptySqiA52k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698203102; x=1698807902; 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=mjdx+X6kSsMpIfxHdDdiHl+XAGtwL5u54eHOXL3lpAg=; b=MMgx+PZMK0m4McKjN0dLRRGedZlfFIGNbgonHB1B5/P4vm5N79lM6yz9Bleo9fs0EC VQHJsx1YL9w3kFhpiVxvjaWx5GCHOZoFizkp3NfOZDg+OjqjOgBdulUl+pBmVuai7aAu CEOcaGhMb+LW2128BXyzFJ1LiVEn0FzUANBrjh+1PCcofKhTAitaVT5lNRtXTomHp5yU AA8tEqbHtKhuQC9/gZXrJ7xsdp4iq+dBxrgVhHp7hnJ9btb1w5Nvclsl3VOafhWctI1O JOGs99OfzlOJs+Pbos33H67EfKk1NaR+/EYxjjDi+DVyYCrTBfK8SEWe0CVRZfOLHh7y bAAA== X-Gm-Message-State: AOJu0Yx5SpfiGi4s+BcksW7cd0nCPZgLdi6CWWnV3OV4hRUsL2GGsAAt /M6I2QoR+fFDkd7pF9cMdC5ONA== X-Google-Smtp-Source: AGHT+IHnKv/Q6GkrsCxWMFAqDfPjHbSHFxqPlRFvdjD/B6Du1hUkwJa1jy0Zs/0LJ6Iafx0gp+chbw== X-Received: by 2002:a05:690c:f0c:b0:5ad:cd52:d6f0 with SMTP id dc12-20020a05690c0f0c00b005adcd52d6f0mr2369100ywb.45.1698203102613; Tue, 24 Oct 2023 20:05:02 -0700 (PDT) Received: from rfd.leadboat.com ([2600:1702:a20:5750::2e]) by smtp.gmail.com with ESMTPSA id v19-20020a81a553000000b00576c727498dsm4643079ywg.92.2023.10.24.20.05.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Oct 2023 20:05:02 -0700 (PDT) Date: Tue, 24 Oct 2023 20:04:59 -0700 From: Noah Misch To: Peter Geoghegan Cc: pgsql-hackers@postgresql.org, Alexander Korotkov Subject: Re: post-recovery amcheck expectations Message-ID: <20231025030459.6f@rfd.leadboat.com> References: <20231005025232.c7.nmisch@google.com> <20231021035457.cb.nmisch@google.com> <20231024022848.87.nmisch@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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, Oct 24, 2023 at 07:03:34PM -0700, Peter Geoghegan wrote: > On Mon, Oct 23, 2023 at 7:28 PM Noah Misch wrote: > > > That makes sense to me. I believe that it's not possible to have a > > > string of consecutive sibling pages that are all half-dead (regardless > > > of the BlockNumber order of sibling pages, even). But I'd probably > > > have written the fix in roughly the same way. Although...maybe you > > > should try to detect a string of half-dead pages? Hard to say if it's > > > worth the trouble. > > > > I imagined a string of half-dead siblings could arise in structure like this: > > > > * 1 > > * / | \ > > * 4 <-> 2 <-> 3 > > > > With events like this: > > > > - DELETE renders blk 4 deletable. > > - Crash with concurrent VACUUM, leaving 4 half-dead after having visited 1-4. > > - DELETE renders blk 2 deletable. > > - Crash with concurrent VACUUM, leaving 2 half-dead after having visited 1-2. > > > > I didn't try to reproduce that, and something may well prevent it. > > FWIW a couple of factors prevent it (in the absence of corruption). These are: > > 1. Only VACUUM can delete pages, and in general the only possible > source of half-dead pages is an unfortunately timed crash/error within > VACUUM. Each interrupted VACUUM can leave behind at most one half-dead > page. Agreed. > 2. One thing that makes VACUUM back out of deleting an empty page is > the presence of a half-dead right sibling leaf page left behind by > some VACUUM that was interrupted at some point in the past -- see > _bt_rightsib_halfdeadflag() for details. > > Obviously, factors 1 and 2 together make three consecutive half-dead > sibling pages impossible. Can't it still happen if the sequence of unfortunately timed crashes causes deletions from left to right? Take this example, expanding the one above. Half-kill 4, crash, half-kill 3, crash, half-kill 2 in: * 1 * / / | \ \ * 4 <-> 3 <-> 2 <-> 1 (That's not to say it has ever happened outside of a test.)