Re: BUG #15703: Segfault in cancelled CALL-Statements

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: julian(dot)schauder(at)gmx(dot)de, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15703: Segfault in cancelled CALL-Statements
Date: 2019-03-20 08:15:14
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Tue, Mar 19, 2019 at 10:04:55AM +0000, PG Bug reporting form wrote:
> there seems to be a SEGFAULT issue with CALL-Procedures once they get
> SIGINT'ed. While currently able to reproduce with non-disclosed
> functions and data- I am working on a minimal report for public
> reproduction.

It would be nice to have a reproducible test case. From what I can
see, we don't have the definition of "procedure" which gets called at
the highest level, so it is not possible to use your example. I have
been playing a bit with query cancellations and some nested
procedures, but could not see an issue:
CREATE TABLE aa (a int);
CREATE OR REPLACE PROCEDURE insert_tuples(num_tuples int)
AS $func$
CALL insert_tuples_inner(num_tuples);
$func$ LANGUAGE plpgsql;
CREATE OR REPLACE PROCEDURE insert_tuples_inner(num_tuples int)
AS $func$
FOR i IN 1..num_tuples LOOP
EXECUTE format('INSERT INTO aa VALUES (' || i || ');');
$func$ LANGUAGE plpgsql;

Then just do that in parallel between two sessions. One for the
while true; do
psql -c "select pg_cancel_backend(pid) from pg_stat_activity where
pid <> pg_backend_pid() and query ~ 'insert_tuples'";
sleep 5;
And another one for the repeated procedure calls, which uses CALL
insert_tuples(1000000) as query to run multiple times.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Amit Langote 2019-03-20 09:07:23 Re: BUG #15668: Server crash in transformPartitionRangeBounds
Previous Message Michael Paquier 2019-03-20 02:09:39 Re: BUG #15704: Possible causes for calling abort () system call during querying database.