PGroonga index-only scan problem with yesterday’s PostgreSQL updates

Поиск
Список
Период
Сортировка
От Anders Kaseorg
Тема PGroonga index-only scan problem with yesterday’s PostgreSQL updates
Дата
Msg-id 4c347490-d734-5fdd-d613-1327601b4e7e@mit.edu
обсуждение исходный текст
Ответы Re: PGroonga index-only scan problem with yesterday’s PostgreSQL updates  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
With yesterday’s release of PostgreSQL 11.15, 12.10, and 13.6 
(presumably 10.20 and 14.2 as well), Zulip’s test suite started failing 
with “variable not found in subplan target list” errors from PostgreSQL 
on a table that has a PGroonga index.  I found the following 
reproduction recipe from a fresh database:

psql (11.15 (Debian 11.15-1.pgdg100+1))
Type "help" for help.

test=# CREATE EXTENSION pgroonga;
CREATE EXTENSION
test=# CREATE TABLE t AS SELECT CAST(c AS text) FROM generate_series(1,
10000) AS c;
SELECT 10000
test=# CREATE INDEX t_c ON t USING pgroonga (c);
CREATE INDEX
test=# VACUUM t;
VACUUM
test=# SELECT COUNT(*) FROM t;
ERROR:  variable not found in subplan target list

I filed https://github.com/pgroonga/pgroonga/issues/203, and confirmed 
with a Git bisection of PostgreSQL that this error first appears with 
ec36745217 (REL_11_15~42) “Fix index-only scan plans, take 2.”  I’m 
aware that this likely just exposed a previously hidden PGroonga bug, 
but I figure PostgreSQL developers might want to know about this anyway 
and help come up with the right fix.  The PGroonga author suggested I 
start a thread here:

https://github.com/pgroonga/pgroonga/issues/203#issuecomment-1036708841
> Thanks for investigating this!
> 
> Our CI is also broken with new PostgreSQL:
> https://github.com/pgroonga/pgroonga/runs/5149762901?check_suite_focus=true
>  
> https://www.postgresql.org/message-id/602391641208390%40iva4-92c901fae84c.qloud-c.yandex.net
> says partial-retrieval index-only scan but our case is
> non-retrievable index-only scan. In non-retrievable index-only scan,
> the error is occurred.
> 
> We asked about non-retrievable index-only scan on the PostgreSQL
> mailing list in the past:
> https://www.postgresql.org/message-id/5148.1584372043%40sss.pgh.pa.us
> We thought non-retrievable index-only scan should not be used but
> PostgreSQL may use it as a valid plan. So I think that our case
> should be supported with postgres/postgres@ec36745 “Fix index-only > scan plans, take 2.”
> 
> Could you ask about this case on the PostgreSQL mailing list
> https://www.postgresql.org/list/pgsql-hackers/ ?
> 
> The following patch fixes our case and PostgreSQL's test cases are
> still passed but a review by the original author is needed:
> 
> --- postgresql-11.15.orig/src/backend/optimizer/plan/setrefs.c    2022-02-08 06:20:23.000000000 +0900

> +++ postgresql-11.15/src/backend/optimizer/plan/setrefs.c    2022-02-12 07:32:20.355567317 +0900

> @@ -1034,7 +1034,7 @@

>      {

>          TargetEntry *indextle = (TargetEntry *) lfirst(lc);

>  

> -        if (!indextle->resjunk)

> +        if (!indextle->resjunk || indextle->expr->type == T_Var)

>              stripped_indextlist = lappend(stripped_indextlist, indextle);

>      }

>  

> ```


Anders



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Justin Pryzby
Дата:
Сообщение: Re: support for MERGE
Следующее
От: Tom Lane
Дата:
Сообщение: Re: PGroonga index-only scan problem with yesterday’s PostgreSQL updates