> On Jul 23, 2018, at 3:06 AM, Michael Paquier <[email protected]> wrote: > > On Mon, Jul 23, 2018 at 12:19:12PM +0530, Prabhat Sahu wrote: >> While testing with PG procedure, I found a memory leak on HEAD, with below >> steps: >> >> postgres=# CREATE OR REPLACE PROCEDURE proc1(v1 INOUT INT) >> AS $$ >> BEGIN >> commit; >> END; $$ LANGUAGE plpgsql; >> CREATE PROCEDURE >> >> postgres=# call proc1(10); >> WARNING: Snapshot reference leak: Snapshot 0x23678e8 still referenced >> v1 >> ---- >> 10 >> (1 row) > > I can reproduce this issue on HEAD and v11, so an open item is added. > Peter, could you look at it?
I tested and was able to reproduce this on head. I also tried a few other other
and was able to reproduce it when the procedure contained a few read-only
statements prior to commit, where the argument passed in was designated "INOUT."
Scenarios 1 & 2 show the leak whereas 3 & 4 do not.
/** Scenario 1: Original scenario */
CREATE OR REPLACE PROCEDURE proc1(v1 INOUT INT)
AS $$
BEGIN
commit;
END; $$ LANGUAGE plpgsql;
CALL proc1(10);
WARNING: Snapshot reference leak: Snapshot 0x7f9519826d18 still referenced
CONTEXT: PL/pgSQL function proc1(integer) line 3 at COMMIT
v1
----
10
(1 row)
/** Scenario 2: call "perform" prior to the commit */
CREATE OR REPLACE PROCEDURE proc2(v1 INOUT INT)
AS $$
BEGIN
PERFORM v1;
COMMIT;
END; $$ LANGUAGE plpgsql;
CALL proc2(10);
WARNING: Snapshot reference leak: Snapshot 0x7f9519826d18 still referenced
CONTEXT: PL/pgSQL function proc2(integer) line 4 at COMMIT
v1
----
10
(1 row)
/** Scenario 3: argument is only IN */
CREATE OR REPLACE PROCEDURE proc3(v1 IN INT)
AS $$
BEGIN
PERFORM v1;
COMMIT;
END; $$ LANGUAGE plpgsql;
CALL proc3(10);
CALL
/** Scenario 4: Same as #2 but with a ROLLBACK */
CREATE OR REPLACE PROCEDURE proc4(v1 INOUT INT)
AS $$
BEGIN
PERFORM v1;
ROLLBACK;
END; $$ LANGUAGE plpgsql;
CALL proc4(10);
CALL
Jonathan
signature.asc
Description: Message signed with OpenPGP
