Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k06sf-0006Tb-S9 for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Jul 2020 17:25:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k06se-0007jL-EZ for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Jul 2020 17:25:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k06sd-0007jE-WF for pgsql-hackers@lists.postgresql.org; Mon, 27 Jul 2020 17:25:40 +0000 Received: from mail-qt1-x842.google.com ([2607:f8b0:4864:20::842]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1k06sX-0005q9-6F for pgsql-hackers@lists.postgresql.org; Mon, 27 Jul 2020 17:25:38 +0000 Received: by mail-qt1-x842.google.com with SMTP id h21so6423514qtp.11 for ; Mon, 27 Jul 2020 10:25:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=Ngqt6KlOca+8atC9fqcjkBi35r30k15byFocTxkxOik=; b=H49Vh9YeTP1uKLHG7F8ky3OK2cItLbx1iMPOnkCelct7liUQKjePf/3FZEjr7tnAvi GKIYlMrI49BvHBVow5F4GI+XcLR0ZYuhBjCatbeanuEpoE5tn8vuMyFV3/8qmCqzC2YG xlVze0nipUdwUVe51QVg+ZPjJ55uPoIBbR9VAxDZ5F+9lHX6887EycxCWd8AvMT0nubZ ECNx4yYxRxUksbkoIkSi+sT/n9qktCNYiuFFbzXOv/RxIbQfMw6e8xZ76i+P7QqBfs3n Ks4QhPjjI/653nP6WGLzhJXAwsBKWOhrsLZTlARiilG4eTc/78lQEajF8qLs7/N+15ql 5CBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=Ngqt6KlOca+8atC9fqcjkBi35r30k15byFocTxkxOik=; b=ZgXMGTE/kmLXaAe7OoDpIRngF3AzPhB7VBsbYlAelz/9FEtiuU3zEkyLYdffp/xejx EIeUeq014quzBOZJy1TB8kjnmMYYq65uoNTmtYoUKPq8Q0FPpnKnOu7ZLc7R0FL+nncj lNax2/M52ngBCpNT2Oin6j0/PZSWZo//uy0AWLFpzCjfZJz0Swj4JDrwA0MHUvYLQIn2 W6If0YY9w/b8exiQ8rCaVbmTLMe+nsrEJpFcH4CeYleGqg89a3kgJ8Xci3RLb0ITyEVn 93S2xciOaKdqekgw/sjm9dZdU59QNXcKarUdorkI8GUkRGAzigMMBwnoESwVDe5Lwtc4 OR1g== X-Gm-Message-State: AOAM532mZv3aLSBnxEBYnYkyF/AXZQ3iBGjH2Khq1t9cDwwKDu02992z /5qEVVgwoVz3r+VH+/0CKUwfQXjlkC21Y1rYL/vD3vxHvtz+Gzhu6NGF4wMgjCo8ERA92Fyg8l0 UMRxhDgsT7SPbYlwpLWTtmzf3wgh6pnnwjVctTaJCN58Pl8Jm8xg2n06P2ywPaUU8ztrKQ+DXdA CD0v9ho/4VprnsOA== X-Google-Smtp-Source: ABdhPJwYEJE+GP8S6Rtzg60zl1kF0gqNRVxLpyPZCclgEKq6/gGC4OaCVN3gWt7RP1kdFmppcDdbew== X-Received: by 2002:aed:3984:: with SMTP id m4mr19674329qte.108.1595870731873; Mon, 27 Jul 2020 10:25:31 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.19.47]) by smtp.gmail.com with ESMTPSA id c22sm20021169qke.2.2020.07.27.10.25.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 10:25:31 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 7275D2A1E6E; Mon, 27 Jul 2020 13:25:29 -0400 (-04) Date: Mon, 27 Jul 2020 13:25:29 -0400 From: Alvaro Herrera To: Anastasia Lubennikova Cc: pgsql-hackers@lists.postgresql.org Subject: Re: [BUG] Error in BRIN summarization Message-ID: <20200727172529.GA12531@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4e07c304-76c8-2645-d4a4-e5706072b7d7@postgrespro.ru> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Jul-27, Anastasia Lubennikova wrote: > Here is the updated version of the fix. > The problem can be reproduced on all supported versions, so I suggest to > backpatch it. > Code slightly changed in v12, so here are two patches: one for versions 9.5 > to 11 and another for versions from 12 to master. Hi Anastasia, thanks for this report and fix. I was considering this last week and noticed that the patch changes the ABI of heap_get_root_tuples, which may be problematic in back branches. I suggest that for unreleased branches (12 and prior) we need to create a new function with the new signature, and keep heap_get_root_tuples unchanged. In 13 and master we don't need that trick, so we can keep the code as you have it in this version of the patch. OffsetNumber heap_get_root_tuples_new(Page page, OffsetNumber *root_offsets) { .. full implementation ... } /* ABI compatibility only */ void heap_get_root_tuples(Page page, OffsetNumber *root_offsets) { (void) heap_get_root_tuples_new(page, root_offsets); } (I was also considering whether it needs to be a loop to reobtain root tuples, in case a concurrent transaction can create a new item while we're checking that item; but I don't think that can really happen for one individual tuple.) Thanks -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services