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 1s5VYV-005jHf-R0 for pgsql-hackers@arkaria.postgresql.org; Fri, 10 May 2024 19:05:19 +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 1s5VYT-000h7E-UH for pgsql-hackers@arkaria.postgresql.org; Fri, 10 May 2024 19:05:18 +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 1s5VYT-000h75-GE for pgsql-hackers@lists.postgresql.org; Fri, 10 May 2024 19:05:17 +0000 Received: from mail-yw1-x1134.google.com ([2607:f8b0:4864:20::1134]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s5VYQ-000NTm-VC for pgsql-hackers@lists.postgresql.org; Fri, 10 May 2024 19:05:16 +0000 Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-6114c9b4d83so21620997b3.3 for ; Fri, 10 May 2024 12:05:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715367914; x=1715972714; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=xTk4X7bHKklBBxZJhAJmOTF0/4cnFB2gq95V2i3o4zw=; b=RBm7OhEhZmMzmXtNIskDOnqWNJ+T87xZd90LUTPxBvGoNA9QwsW9abZjEFsbKtOqgg YqzQBb7eh3Ib3BO3sPAhCPgBx0plcsFmyDOVkPe30YyBlaiXGqYJUdqgEqDo/F9apqvN 9bqXGSfi0g/nvcMtaBE+31F9KInVRHn6FN2FicOF3FiBST/xmQL2YRJH9iE+/MMxk7Q3 cSoj1aD93ZpdGJByo/MEvZVRHtVYpQl+555vIjWmdjWOdDDWU1NcRXK3l6KpjHrgmmjK 4DpW8ebnqsNrNDBDjjyLfzFhgRILz0OgoEY7CI7xO+wcjtV75NziSWq63A1KH1F+7RZ/ gRgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715367914; x=1715972714; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xTk4X7bHKklBBxZJhAJmOTF0/4cnFB2gq95V2i3o4zw=; b=TPknx4VPwHJGtLDYv+vWGFZ54+rPR0EcE5sCbRWP9hxzih7dBWKrqpAqIUVHGFgLYz lyDSaXnMZE6QEbT8VXZqNbB329/Mk6isMXgUqacyskzQggm0GnZPX+pKCom35VF/0DYS FwbdDJf0vaqwt21uwlF/E1sXcifR3lAcpx2OgQeSQ9avs2sYn3W7WurVm7xwQwAmJwl+ iBRoRgXMOvQLP31j68r4ehnNRnx/xo9vfwN+esUGkJfIOL2CeRfuABkq8mYL58KHxxaa IgLHkaEh01Wkcn+lDsDsF14yy1U2BfaIK0pGbj+ZLr5jS2muqRUMV40RDJ8AAPUZio2I I5cQ== X-Forwarded-Encrypted: i=1; AJvYcCUm1KF3o45sQukU5b3zEjAPMmqJX9zNb4oUfM/i7kIGVfihtqBoZbyP06yNVO9bKXCaAq+x6AlOvRbHSueutd0hLsj7UUtpX7MTkzZkr09YtImV X-Gm-Message-State: AOJu0YwqQHuS4jlkGHw1Nr0F5PHB4S1QuBgndztFckXhyQnnJisr2yOY gDL/0XL35i/A6Ed1UC1WRk2bOWUwnTdDjp8uCvxiAHAjhh7EY+hhI22yL+DQ2JOjxSU5GwtdVKr /6foFJd+iLKp4DiLdlNj3TGY+NzY= X-Google-Smtp-Source: AGHT+IEK8y6UG6Gsmdi3VzXn62z4K4f4WQDx0v16ekQG+Mox/T5Tm59OVa4HdCplDOxGRcU0xGRZLKsY+/P5VO+QqLQ= X-Received: by 2002:a25:83c4:0:b0:de4:8c46:e7f9 with SMTP id 3f1490d57ef6-dee4f1baaf6mr3439799276.31.1715367913890; Fri, 10 May 2024 12:05:13 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: <8635D8B1-45B7-4D67-86C7-D6ECB4F10B11@enterprisedb.com> From: Alexander Korotkov Date: Fri, 10 May 2024 22:05:01 +0300 Message-ID: Subject: Re: [PATCH] Improve amcheck to also check UNIQUE constraint in btree index. To: Mark Dilger 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-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, May 10, 2024 at 8:35=E2=80=AFPM Mark Dilger wrote: > > On May 10, 2024, at 5:10 AM, Pavel Borisov wro= te: > > On Fri, 10 May 2024 at 12:39, Alexander Korotkov = wrote: > > On Fri, May 10, 2024 at 3:43=E2=80=AFAM Tom Lane wr= ote: > > > Alexander Korotkov writes: > > > > The revised patchset is attached. I applied cosmetical changes. I= 'm > > > > going to push it if no objections. > > > > > > Is this really suitable material to be pushing post-feature-freeze? > > > It doesn't look like it's fixing any new-in-v17 issues. > > > > These are code improvements to the 5ae2087202, which answer critics in > > the thread. 0001 comprises an optimization, but it's rather small and > > simple. 0002 and 0003 contain refactoring. 0004 contains better > > error reporting. For me this looks like pretty similar to what others > > commit post-FF, isn't it? > > I've re-checked patches v2. Differences from v1 are in improving naming= /pgindent's/commit messages. > > In 0002 order of variables in struct BtreeLastVisibleEntry changed. Thi= s doesn't change code behavior. > > > > Patch v2-0003 doesn't contain credits and a discussion link. All other = patches do. > > > > Overall, patches contain small performance optimization (0001), code re= factoring and error reporting changes. IMO they could be pushed post-FF. > > v2-0001's commit message itself says, "This commit implements skipping ke= ys". I take no position on the correctness or value of the improvement, but= it seems out of scope post feature freeze. The patch seems to postpone un= iqueness checking until later in the scan than what the prior version did, = and that kind of change could require more analysis than we have time for a= t this point in the release cycle. Formally this could be classified as algorithmic change and probably should be postponed to the next release. But that's quite local optimization, which just postpones a function call within the same iteration of loop. And the effect is huge. Probably we could allow this post-FF in the sake of quality release, given it's very local change with a huge effect. > v2-0002 does appear to just be refactoring. I don't care for a small por= tion of that patch, but I doubt it violates the post feature freeze rules. = In particular: > > + BtreeLastVisibleEntry lVis =3D {InvalidBlockNumber, InvalidOffsetNu= mber, -1, NULL}; I don't understand what is the problem with this line and post feature freeze rules. Please, explain it more. > v2-0003 may be an improvement in some way, but it compounds some preexist= ing confusion also. There is already a member of the BtreeCheckState calle= d "target" and a memory context in that struct called "targetcontext". Tha= t context is used to allocate pages "state->target", "rightpage", "child" a= nd "page", but not "metapage". Perhaps "targetcontext" is a poor choice of= name? "notmetacontext" is a terrible name, but closer to describing the p= urpose of the memory context. Care to propose something sensible? > > Prior to applying v2-0003, the rightpage was stored in state->target, and= continued to be in state->target later when entering > > /* > * * Downlink check * > * > * Additional check of child items iff this is an internal page a= nd > * caller holds a ShareLock. This happens for every downlink (it= em) > * in target excluding the negative-infinity downlink (again, thi= s is > * because it has no useful value to compare). > */ > if (!P_ISLEAF(topaque) && state->readonly) > bt_child_check(state, skey, offset); > > and thereafter. Now, the rightpage of state->target is created, checked,= and free'd, and then the old state->target gets processed in the downlink = check and thereafter. This is either introducing a bug, or fixing one, but= the commit message is totally ambiguous about whether this is a bugfix or = a code cleanup or something else? I think this kind of patch should have a= super clear commit message about what it thinks it is doing. 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. 0002 and 0003 don't address any bugs, but It would be very nice to accept them, because it would simplify future backpatching in this area. > v2-0004 guards against a real threat, and is reasonable post feature free= ze Ok. ------ Regards, Alexander Korotkov Supabase