A potential memory leak on Merge Join when Sort node is not below Materialize node - Mailing list pgsql-hackers

From Ranier Vilela
Subject A potential memory leak on Merge Join when Sort node is not below Materialize node
Date
Msg-id CAEudQAr9jaGCfR+5zf=yPqQir5MGmRF9D=Jv61o43VWiR+PQoQ@mail.gmail.com
Whole thread Raw
Responses Re: A potential memory leak on Merge Join when Sort node is not below Materialize node
List pgsql-hackers

>CREATE TABLE t1 (a text);
>CREATE TABLE t2 (a text);

>-- make the text a little large by adding 100000000000
>INSERT INTO t1 SELECT (100000000000+i%1000)::text FROM
>generate_series(0,10000000) i;

>-- make the text a little large by adding 100000000000
>INSERT INTO t2 SELECT (100000000000+i%10000)::text FROM
>generate_series(0,10000000) i;

>-- to simplify the explain plan, not strictly necessary
>SET max_parallel_workers_per_gather TO 0;

>-- these two are necessary so that the problem is triggered
>-- these are helpful to use Merge join and avoid materialization
>SET enable_hashjoin TO false;
>SET enable_material TO false;

>-- the join is on a TEXT column
>-- when the join is on INT column with a similar setup, I do not observe
>this problem
>SELECT count(*) FROM t1 JOIN t2 USING (a);
>```

>The explain output for the query like the following:
>```
>explain SELECT count(*) FROM t1 JOIN t2 USING (a);

I run your test here with a fix attached.

Can you retake your test with the patch attached?regards,

Ranier Vilela

Attachment

pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: longfin and tamandua aren't too happy but I'm not sure why
Next
From: Aleksander Alekseev
Date:
Subject: Refactor UnpinBuffer()