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 1s5bIS-006a5x-VA for pgsql-hackers@arkaria.postgresql.org; Sat, 11 May 2024 01:13: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 1s5bIR-002QNQ-5C for pgsql-hackers@arkaria.postgresql.org; Sat, 11 May 2024 01:13:07 +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 1s5bIQ-002QN8-Mh for pgsql-hackers@lists.postgresql.org; Sat, 11 May 2024 01:13:07 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s5bIN-000PuM-8E for pgsql-hackers@lists.postgresql.org; Sat, 11 May 2024 01:13:05 +0000 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6f44dd41a5cso2690696b3a.0 for ; Fri, 10 May 2024 18:13:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1715389981; x=1715994781; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bBoNn/pNhR3Z+qBHlQJz4yMytXP/MkRL3qyBljNlzgA=; b=W4JbUHGVN4i+dD77bbKLejKuflt1IE0zB2abAWkQXC5M9CMRDjlIbvnBI0a6HDoqfP Mr68H6WkMadExxOADMdy0Ixoxr83HcSS33vsTLcP7ftufpBmG6SvRJUCRM90ygzZTFL7 Otzwb1W8psufOmcJcJfbPPIYbNs2EKLF59byV1mHw0KY1bjO+G+1uM6eDlRTOyaF5BwQ ObZH3obyUs+y9E46HLrSsJfwyV20hkVXQdTsrnSRRhkxxyHskBUbT1C/P8+e+Ia2hdHs 12Xjb+aRj1bJhgLUoINSlLc8RIUNR1/asq0jmbNwznID2ImKzvb9TInM+xo/oi7bvAil UfxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715389981; x=1715994781; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bBoNn/pNhR3Z+qBHlQJz4yMytXP/MkRL3qyBljNlzgA=; b=KE+mbrEa7GTMlDMPRxCIUnskdo2u81Z/PmQw5R3SUIxYGyIyBcTfDWH2N9nWAmkFga cl7uV5B5UtQKw0nm7ob7ig4L1ybPHIFcM3Ab9a+XXi7eXEW2+aURZWsNxUYPPfrdS81y 8GCIL4dUEbpZZP+e8w8u5PLDzPZHlEkfJWiKuFj9+CKrj+HlnpYjtyLMjp6Xn0+NlrNz yDHQc21qYAfLuP7YUErohbIbR4r/m7ZcdMwDb1CJ3P16o8nShQsGxOc00y1/aqi+tFUD zf3kGN2cs6zxPGCnklFRYqD0FrT8YrZKzNp+dAsYh2JIw16ZMUhcHCPrdzjpvBOQgeYL hb/w== X-Forwarded-Encrypted: i=1; AJvYcCUxEB9ztnQmlRadssNEE5v90ZkfhsEAD1q9C4teMRkriT26fqbeWN9GTwoO3Rsj9qO6yaxClNOqlf6/Hpunwmr0CCGZBVyakqZfy6ZEGR0TXVP8 X-Gm-Message-State: AOJu0YxB+S8ndWRUD/ec2MmG/UReLrOnQaJl7Yth1PAv7v8EeMbjvMDx bBepS0eMg4+Ge7GFFXDKlawXGxhGQXML5wPjQYIGi0HLRcGswIXZy4uEhm0t9Q== X-Google-Smtp-Source: AGHT+IG6tDcBO+9LH59X+FwqiiPKGWehUNTED5U5pityAVbAyTFTyl2nCEsZvY55i+XOcaGP0dbEKA== X-Received: by 2002:a05:6a20:550a:b0:1af:d228:ca5c with SMTP id adf61e73a8af0-1afde09f3e6mr4332076637.5.1715389981556; Fri, 10 May 2024 18:13:01 -0700 (PDT) Received: from smtpclient.apple (24-113-197-127.wavecable.com. [24.113.197.127]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2b628ea59absm5695122a91.47.2024.05.10.18.13.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 May 2024 18:13:01 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6.1.1\)) Subject: Re: [PATCH] Improve amcheck to also check UNIQUE constraint in btree index. From: Mark Dilger In-Reply-To: Date: Fri, 10 May 2024 18:12:57 -0700 Cc: Pavel Borisov , Tom Lane , Noah Misch , Peter Eisentraut , Aleksander Alekseev , Postgres hackers , Maxim Orlov , Andres Freund , Greg Stark , Julien Rouhaud , David Steele , Peter Geoghegan , Maxim Orlov , lubennikovaav@gmail.com Content-Transfer-Encoding: quoted-printable Message-Id: References: <20220922151328.lakwdytvwnyyif3b@awork3.anarazel.de> <8c74cc5e-4b97-4cd7-9aaf-67886822a78c@eisentraut.org> <20240501022412.85@rfd.leadboat.com> <1375614.1715301775@sss.pgh.pa.us> <8635D8B1-45B7-4D67-86C7-D6ECB4F10B11@enterprisedb.com> To: Alexander Korotkov X-Mailer: Apple Mail (2.3731.700.6.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On May 10, 2024, at 12:05 PM, Alexander Korotkov = wrote: >=20 > The only bt_target_page_check() caller is > bt_check_level_from_leftmost(), which overrides state->target in the > next iteration anyway. I think the patch is just refactoring to > eliminate the confusion pointer by Peter Geoghegan upthread. I find your argument unconvincing. After bt_target_page_check() returns at line 919, and before = bt_check_level_from_leftmost() overrides state->target in the next = iteration, bt_check_level_from_leftmost() conditionally fetches an item = from the page referenced by state->target. See line 963. I'm left with four possibilities: 1) bt_target_page_check() never gets to the code that uses "rightpage" = rather than "state->target" in the same iteration where = bt_check_level_from_leftmost() conditionally fetches an item from = state->target, so the change you're making doesn't matter. 2) The code prior to v2-0003 was wrong, having changed state->target in = an inappropriate way, causing the wrong thing to happen at what is now = line 963. The patch fixes the bug, because state->target no longer gets = overwritten where you are now using "rightpage" for the value. 3) The code used to work, having set up state->target correctly in the = place where you are now using "rightpage", but v2-0003 has broken that.=20= 4) It's been broken all along and your patch just changes from wrong to = wrong. If you believe (1) is true, then I'm complaining that you are relying = far to much on action at a distance, and that you are not documenting = it. Even with documentation of this interrelationship, I'd be unhappy = with how brittle the code is. I cannot easily discern that the two = don't ever happen in the same iteration, and I'm not at all convinced = one way or the other. I tried to set up some Asserts about that, but = none of the test cases actually reach the new code, so adding Asserts = doesn't help to investigate the question. If (2) is true, then I'm complaining that the commit message doesn't = mention the fact that this is a bug fix. Bug fixes should be clearly = documented as such, otherwise future work might assume the commit can be = reverted with only stylistic consequences. If (3) is true, then I'm complaining that the patch is flat busted. If (4) is true, then maybe we should revert the entire feature, or have = a discussion of mitigation efforts that are needed. Regardless of which of 1..4 you pick, I think it could all do with more = regression test coverage. For reference, I said something similar earlier today in another email = to this thread: This patch introduces a change that stores a new page into variable = "rightpage" rather than overwriting "state->target", which the old = implementation most certainly did. That means that after returning from = bt_target_page_check() into the calling function = bt_check_level_from_leftmost() the value in state->target is not what it = would have been prior to this patch. Now, that'd be irrelevant if = nobody goes on to consult that value, but just 44 lines further down in = bt_check_level_from_leftmost() state->target is clearly used. So the = behavior at that point is changing between the old and new versions of = the code, and I think I'm within reason to ask if it was wrong before = the patch, wrong after the patch, or something else? Is this a bug = being introduced, being fixed, or ... ? =E2=80=94 Mark Dilger EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company