Re: Memory leak in WAL sender with pgoutput (v10~)
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Postgres hackers <pgsql-hackers@lists.postgresql.org>
Cc: Amit Kapila <amit.kapila16@gmail.com>
Date: 2024-11-30T03:58:44Z
Lists: pgsql-hackers
On Fri, Nov 29, 2024 at 11:05:51AM +0900, Michael Paquier wrote: > This is a follow-up of ea792bfd93ab and this thread where I've noticed > that some memory was still leaking when running sysbench with a > logical replication setup: > https://www.postgresql.org/message-id/Zz7SRcBXxhOYngOr@paquier.xyz Adding Amit in CC in case, as we've talked about this topic offlist. > This problem exists since the introduction of logical replication, > down to v10. It would be sad to have an extra loop on publications to > free explicitely the publication names, and the issue would still be > hidden to the existing callers of GetPublication(), so I'd suggest to > change the Publication structure to use a NAMEDATALEN string to force > the free to happen, as in the attached. > > That means an ABI break. I've looked around and did not notice any > out-of-core code relying on sizeof(Publication). That does not mean > that nothing would break, of course, but the odds should be pretty > good as this is a rather internal structure. One way would be to just > fix that on HEAD and call it a day, but I'm aware of heavy logirep > users whose workloads would be able to see memory bloating because > they maintain WAL senders around. After sleeping on that, and because the leak is minimal, I'm thinking about just applying the fix only on HEAD and call it a day. This changes the structure of Publication so as we use a char[NAMEDATALEN] rather than a char*, avoiding the pstrdup(), for the publication name and free it in the list_free_deep() when reloading the list of publications. If there are any objections or comments, feel free. I'll revisit that again around the middle of next week. -- Michael
Commits
-
Fix memory leak in pgoutput with relation attribute map
- a786cf04df76 13.19 landed
- c53d90bb47ae 14.16 landed
- da8bd5d424e0 15.11 landed
- e3a27fd06d06 16.7 landed
- 836435424ba8 17.3 landed
- c9b3d4909bbf 18.0 landed
-
Fix memory leak in pgoutput with publication list cache
- ba230ce40faa 13.19 landed
- cfd6cbcf9be0 14.16 landed
- 6c9b3975407d 15.11 landed
- 4d45e7490c41 16.7 landed
- bbe68c13abe0 17.3 landed
- f0c569d71515 18.0 landed
-
Allow specifying row filters for logical replication of tables.
- 52e4f0cd472d 15.0 cited