mirror of https://github.com/postgres/postgres
The gzip basebackup sink called deflateInit2() in begin_archive() but never called deflateEnd(), leaking zlib's internal compression state (~256KB per archive) until the memory context of the base backup is destroyed. The code tree has already a matching deflateEnd() call for each deflateInit[2]() call (pgrypto, etc.), except for the file touched in this commit, so this brings more consistency for all the compression methods. The server-side LZ4 and zstd implementations require a dedicated cleanup callback as they allocate their state outside the context of a palloc(). As currently used, deflateInit2() is called once per tablespace in a single backup. Memory would slightly bloat only when dealing with many tablespaces at once, not across multiple base backups so this is not worth a backpatch. This change could matter for future uses of this code. zlib allows the definition of memory allocation and free callbacks in the z_stream object given to a deflateInit[2](). The base backup backend code relies on palloc() for the allocations and deflateEnd() internally only cleans up memory (no fd allocation for example). Author: Jianghua Yang <yjhjstz@gmail.com> Discussion: https://postgr.es/m/CAAZLFmQNJ0QNArpWEOZXwv=vbumcWKEHz-b1me5gBqRqG67EwQ@mail.gmail.commaster
parent
69c57466a7
commit
ded9754804
Loading…
Reference in new issue