Re: BUG #17355: Server crashes on ExecReScanForeignScan in postgres_fdw when accessing foreign partition

Etsuro Fujita <etsuro.fujita@gmail.com>

From: Etsuro Fujita <etsuro.fujita@gmail.com>
To: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2022-01-06T09:56:01Z
Lists: pgsql-bugs
On Thu, Jan 6, 2022 at 5:25 PM PG Bug reporting form
<noreply@postgresql.org> wrote:
> When running the following script (with 20 concurrent insert/update/delete
> queries):
> cat << 'EOF' | psql postgres
> CREATE EXTENSION postgres_fdw;
>
> CREATE SERVER testserver1 FOREIGN DATA WRAPPER postgres_fdw;
> DO $d$
>     BEGIN
>         EXECUTE $$CREATE SERVER loopback FOREIGN DATA WRAPPER postgres_fdw
>             OPTIONS (dbname '$$||current_database()||$$',
>                      port '$$||current_setting('port')||$$'
>             )$$;
>     END;
> $d$;
>
> CREATE USER MAPPING FOR CURRENT_USER SERVER loopback;
> CREATE TABLE async_pt (a int, b int) PARTITION BY RANGE (a);
> CREATE TABLE base_tbl2 (a int, b int);
> CREATE FOREIGN TABLE async_p2 PARTITION OF async_pt FOR VALUES FROM (2000)
> TO (3000)
>   SERVER loopback OPTIONS (table_name 'base_tbl2');
> CREATE TABLE async_p3 PARTITION OF async_pt FOR VALUES FROM (3000) TO
> (4000);
> EOF
>
> for i in `seq 20`; do
> cat << 'EOF' | psql postgres >psql-$i.log &
> INSERT INTO async_pt SELECT i FROM generate_series(3000, 3100) i;
> DELETE FROM async_pt;
> UPDATE async_pt SET a = a;
> EOF
> done
> wait
>
> I get crashes with the following stacktrace:

I haven't tried to reproduce this yet, but I have one question: did
you set the async_capable option to true?

Thanks for the report!

Best regards,
Etsuro Fujita



Commits

  1. Further fix for EvalPlanQual with mix of local and foreign partitions.

  2. Fix segfault during EvalPlanQual with mix of local and foreign partitions.

  3. Rework planning and execution of UPDATE and DELETE.