Re: assertion failure at cost_memoize_rescan()

From: Kohei KaiGai <kaigai(at)heterodb(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: assertion failure at cost_memoize_rescan()
Date: 2024-06-18 02:23:21
Message-ID: CAOP8fzaLocNELNs_50depJpMDVV-Rj6O+ESK2kMZgoWcB=Y_nA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2024年6月17日(月) 8:27 David Rowley <dgrowleyml(at)gmail(dot)com>:
>
> On Mon, 17 Jun 2024 at 10:23, Tomas Vondra
> <tomas(dot)vondra(at)enterprisedb(dot)com> wrote:
> > Interesting. Seems like a bug due to the two places clamping the values
> > inconsistently. It probably does not matter in other contexts because we
> > don't subtract the values like this, but here it triggers the assert.
> >
> > I guess the simplest fix would be to clamp "calls" the same way before
> > calculating hit_ratio. That makes the ">= 0" part of the assert somewhat
> > pointless, though.
>
> "calls" comes from the value passed as the final parameter in
> create_memoize_path().
>
> There's really only one call to that function and that's in get_memoize_path().
>
> return (Path *) create_memoize_path(root,
> innerrel,
> inner_path,
> param_exprs,
> hash_operators,
> extra->inner_unique,
> binary_mode,
> outer_path->rows);
>
> It would be good to know what type of Path outer_path is. Normally
> we'll clamp_row_est() on that field. I suspect we must have some Path
> type that isn't doing that.
>
> KaiGai-san, what type of Path is outer_path?
>
It is CustomPath with rows = 3251872.916666667.
(I'm not certain whether the non-integer value in the estimated rows
is legal or not.)

According to the crash dump, try_partial_nestloop_path() takes this two paths,

(gdb) up
#7 0x0000000000860fc5 in try_partial_nestloop_path (root=0x133a968,
joinrel=0x15258d8, outer_path=0x1513c98, inner_path=0x15264c8,
pathkeys=0x0, jointype=JOIN_INNER, extra=0x7ffc494cddf0) at
joinpath.c:887
/home/kaigai/source/pgsql-16/src/backend/optimizer/path/joinpath.c:887:30713:beg:0x860fc5

(gdb) p *(CustomPath *)outer_path
$13 = {path = {type = T_CustomPath, pathtype = T_CustomScan, parent =
0x1513058, pathtarget = 0x1513268, param_info = 0x0, parallel_aware =
true, parallel_safe = true, parallel_workers = 2, rows =
3251872.916666667, startup_cost = 41886.752500000002,
total_cost = 12348693.488611111, pathkeys = 0x0}, flags = 4,
custom_paths = 0x1514788, custom_private = 0x1514ee8, methods =
0x7f45211feca0 <gpujoin_path_methods>}

(gdb) p *(MemoizePath *)inner_path
$14 = {path = {type = T_MemoizePath, pathtype = T_Memoize, parent =
0x14dc800, pathtarget = 0x14dca10, param_info = 0x150d8a8,
parallel_aware = false, parallel_safe = true, parallel_workers = 0,
rows = 1, startup_cost = 0.44500000000000001,
total_cost = 8.4284913207446568, pathkeys = 0x150d5c8}, subpath =
0x150d148, hash_operators = 0x1526428, param_exprs = 0x1526478,
singlerow = true, binary_mode = false, calls = 3251872.916666667,
est_entries = 3251873}

Best regards,
--
HeteroDB, Inc / The PG-Strom Project
KaiGai Kohei <kaigai(at)heterodb(dot)com>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2024-06-18 02:32:56 Missing docs for new enable_group_by_reordering GUC
Previous Message Chapman Flack 2024-06-18 02:17:06 Re: jsonpath: Missing regex_like && starts with Errors?