Re: Avoid choose invalid number of partitions (src/backend/executor/nodeAgg.c)

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Avoid choose invalid number of partitions (src/backend/executor/nodeAgg.c)
Date: 2021-08-30 10:44:13
Message-ID: CAApHDvof3AEVFZTT3MArh4Tq1cAuCJb_wk8u7FV5KMzJNhU4GQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 30 Jun 2021 at 02:33, Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> wrote:
> hash_choose_num_partitions function has issues.
> There are at least two path calls made with used_bits = 0.
> See at hashagg_spill_init.

> On Windows 64 bits (HEAD) fails with partition_prune:
> parallel group (11 tests): reloptions hash_part partition_info explain compression resultcache indexing partition_join partition_aggregate partition_prune tuplesort
> partition_join ... ok 3495 ms
> partition_prune ... FAILED 4926 ms
>
> diff -w -U3 C:/dll/postgres/postgres_head/src/test/regress/expected/partition_prune.out C:/dll/postgres/postgres_head/src/test/regress/results/partition_prune.out
> --- C:/dll/postgres/postgres_head/src/test/regress/expected/partition_prune.out 2021-06-23 11:11:26.489575100 -0300
> +++ C:/dll/postgres/postgres_head/src/test/regress/results/partition_prune.out 2021-06-29 10:54:43.103775700 -0300
> @@ -2660,7 +2660,7 @@
> --------------------------------------------------------------------------
> Nested Loop (actual rows=3 loops=1)
> -> Seq Scan on tbl1 (actual rows=5 loops=1)
> - -> Append (actual rows=1 loops=5)
> + -> Append (actual rows=0 loops=5)
> -> Index Scan using tprt1_idx on tprt_1 (never executed)
> Index Cond: (col1 = tbl1.col1)
> -> Index Scan using tprt2_idx on tprt_2 (actual rows=1 loops=2)
>
> With patch attached:
> parallel group (11 tests): partition_info hash_part resultcache reloptions explain compression indexing partition_aggregate partition_join tuplesort partition_prune
> partition_join ... ok 3013 ms
> partition_prune ... ok 3959 ms

This failure was reported to me along with this thread so I had a look at it.

Firstly, I'm a bit confused as to why you think making a change in
nodeAgg.c would have any effect on a plan that does not contain any
aggregate node.

As for the regression test failure. I can recreate it, but I did have
to install VS2019 version 16.9.3 from
https://docs.microsoft.com/en-us/visualstudio/releases/2019/history

This basically boils down to the 16.9.3 compiler outputting "0" for:

#include <stdio.h>

int main(void)
{
printf("%.0f\n", 0.59999999999999998);
return 0;
}

but we expect it to output "1".

We name use of the provided sprintf() function in snprintf.c line 1188 with:

vallen = sprintf(convert, fmt, prec, value);

I don't see the problem in more recent versions of VS2019, but I
didn't go to the trouble of figuring out exactly which version this
was fixed in.

David

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Denis Hirn 2021-08-30 10:52:31 Re: [PATCH] Allow multiple recursive self-references
Previous Message Bharath Rupireddy 2021-08-30 10:31:24 Re: Trap errors from streaming child in pg_basebackup to exit early