Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VFXrp-0005Bd-QY for pgsql-bugs@arkaria.postgresql.org; Fri, 30 Aug 2013 23:12:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VFXrp-0007NB-9g for pgsql-bugs@arkaria.postgresql.org; Fri, 30 Aug 2013 23:12:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VFXro-0007N4-Be for pgsql-bugs@postgresql.org; Fri, 30 Aug 2013 23:12:36 +0000 Received: from moutng.kundenserver.de ([212.227.17.10]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VFXrl-0006mB-Kk for pgsql-bugs@postgresql.org; Fri, 30 Aug 2013 23:12:36 +0000 Received: from anarazel.de (p54AF4A79.dip0.t-ipconnect.de [84.175.74.121]) by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis) id 0MT86g-1VQ1Qs00l4-00SBC9; Sat, 31 Aug 2013 01:12:32 +0200 Received: by anarazel.de (Postfix, from userid 1000) id 600BB100A6D; Sat, 31 Aug 2013 01:12:31 +0200 (CEST) Date: Sat, 31 Aug 2013 01:12:31 +0200 From: Andres Freund To: Tom Lane Cc: terje@elde.net, pgsql-bugs@postgresql.org Subject: Re: BUG #8410: out of binary heap slots Message-ID: <20130830231231.GC1138@awork2.anarazel.de> References: <20130830210015.GA8932@awork2.anarazel.de> <20130830210525.GB8932@awork2.anarazel.de> <20130830214429.GE8932@awork2.anarazel.de> <22149.1377903353@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <22149.1377903353@sss.pgh.pa.us> X-Provags-ID: V02:K0:7a4G4Br885knv8uExmXEW9wZnMvZdapniK09NdWQ9aN HBVuoh6/hFhoe6U5c80Dk7vu7YYCCHuCTeYBPPYz6ztnliJgFb oJobQNXFPmqEexZFAN/ijvRklynbvPXWlHZQzGTidxtiD6GimC lXa4AAEU2F7OQm65SYzwD6G2Ndf+Z2a68asGKlBMRSqcfoTr84 LYFsxWRGqQyt9Thx4bFqkDpW8L+tKhUNSydip2IUBneBElMLsX wQnk/eIlQL5Ww64xh9Zv9dYYauwK4HPBOk/Vr/b4hrqn7EI91E hEaoseCDA5k7A7M2UvITkWIOmi9VsOK3nkx9bxQ+1zvImzjJ2e DJnZn6+y2AoIKeUKE46CnZQ8K7yo+zbQGfHlatByS X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 2013-08-30 18:55:53 -0400, Tom Lane wrote: > Andres Freund writes: > > On 2013-08-30 23:05:25 +0200, Andres Freund wrote: > >> ExecReScanMergeAppend resets ms_initialized, but doesn't clear the > >> binaryheap. Thus no new elements fit. > > > Ok, patch for that attached. > > I think the comments need a bit of copy-editing, but looks good otherwise. > Will fix and commit. Thanks. > > Should we add > > SELECT (SELECT g.i FROM ((SELECT random()::int ORDER BY 1 OFFSET 0) UNION ALL (SELECT random()::int ORDER BY 1 OFFSET 0)) f(i) ORDER BY f.i LIMIT 1) FROM generate_series(1, 10) g(i); > > as a regression test? I slightly on the "no" side... > > Not sure. It's pretty disturbing that this wasn't caught earlier; > it seems to me that means there's no regression coverage that hits > ExecReScanMergeAppend. However, I don't much like this specific test case > because it seems like hitting the bug could depend on what series of > random values you get. Hm, that should be fixable. How about: SELECT -- correlated subquery, with dependency on outer query, to force rescans -- which will be planned as a merge-append. (SELECT g.i FROM ( (SELECT * FROM generate_series(1, 2) ORDER BY 1) UNION ALL (SELECT * FROM generate_series(1, 2) ORDER BY 1) ) f(i) ORDER BY f.i LIMIT 1) FROM generate_series(1, 3) g(i); I couldn't find a simpler testcase within some minutes... Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs