SnapBuildSerialize function forgot pfree variable ondisk_c

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

SnapBuildSerialize function forgot pfree variable ondisk_c

范孝剑(康贤)
Hi all,
    When I tested logical decoding, I found that walsender process memory usage grow very high, by debugging,  I found SnapBuildSerialize palloc memory for variable ondisk_c, but don't pfree it at last.
So when master LogStandbySnapshot() too frequently, walsender memory will grow very high and OOM finally.

Reply | Threaded
Open this post in threaded view
|

Re: SnapBuildSerialize function forgot pfree variable ondisk_c

akapila
On Thu, Nov 5, 2020 at 2:06 PM 范孝剑(康贤) <[hidden email]> wrote:
>
> Hi all,
>     When I tested logical decoding, I found that walsender process memory usage grow very high, by debugging,  I found SnapBuildSerialize palloc memory for variable ondisk_c, but don't pfree it at last.
>

By looking at code, it is clear that it is good to free the memory
allocated for variable ondisk_c.

> So when master LogStandbySnapshot() too frequently, walsender memory will grow very high and OOM finally.
>

Is there any particular scenario where you are seeing this behavior?
Do you have any reproducible test case? Have you confirmed that after
freeing that memory your problem is solved? It is not clear to me why
other users of Logical Replication are not facing this issue?

--
With Regards,
Amit Kapila.


Reply | Threaded
Open this post in threaded view
|

回复:SnapBuildSerialize function forgot pfree variable ondisk_c

范孝剑(康贤)
If we create logical slot frequently, every time when creating a logical slot, it will generate a LogStandbySnapshot wal record.

Session A:
do language plpgsql $$
declare
  v_text text := 'a';
begin
  for i in 1..290000 loop
    execute $_$select pg_create_logical_replication_slot('logical_slot4', 'test_decoding')$_$;
    execute $_$select pg_drop_replication_slot('logical_slot4')$_$;
  end loop;
exception when others then
  raise notice 'execute  failed.';
end;
$$;

Session B:
pg_recvlogical -d postgres --start -S test -f test.log




------------------------------------------------------------------
发件人:Amit Kapila <[hidden email]>
发送时间:2020年11月6日(星期五) 11:21
收件人:范孝剑(康贤) <[hidden email]>
抄 送:pgsql-bugs <[hidden email]>
主 题:Re: SnapBuildSerialize function forgot pfree variable ondisk_c

On Thu, Nov 5, 2020 at 2:06 PM 范孝剑(康贤) <[hidden email]> wrote:
>
> Hi all,
>     When I tested logical decoding, I found that walsender process memory usage grow very high, by debugging,  I found SnapBuildSerialize palloc memory for variable ondisk_c, but don't pfree it at last.
>

By looking at code, it is clear that it is good to free the memory
allocated for variable ondisk_c.

> So when master LogStandbySnapshot() too frequently, walsender memory will grow very high and OOM finally.
>

Is there any particular scenario where you are seeing this behavior?
Do you have any reproducible test case? Have you confirmed that after
freeing that memory your problem is solved? It is not clear to me why
other users of Logical Replication are not facing this issue?

-- 
With Regards,
Amit Kapila.