From 460994c930c39d736faffc0dcdf211642db8c89b Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Sun, 15 Sep 2024 11:35:18 +0200 Subject: [PATCH] Reset per compressed row memory context during tuple filtering When a batch was skipped due to compression tuple filtering the per compressed row memory context would not be reset leading to memory usage increasing linearly with number of consecutive filtered batches. --- .unreleased/pr_7270 | 1 + tsl/src/compression/compression.c | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) create mode 100644 .unreleased/pr_7270 diff --git a/.unreleased/pr_7270 b/.unreleased/pr_7270 new file mode 100644 index 00000000000..ca437d53bf6 --- /dev/null +++ b/.unreleased/pr_7270 @@ -0,0 +1 @@ +Fixes: #7270 Fix memory leak in compressed DML batch filtering diff --git a/tsl/src/compression/compression.c b/tsl/src/compression/compression.c index b3f3e53a40e..78b46453270 100644 --- a/tsl/src/compression/compression.c +++ b/tsl/src/compression/compression.c @@ -1471,6 +1471,7 @@ build_decompressor(Relation in_rel, Relation out_rel) void row_decompressor_reset(RowDecompressor *decompressor) { + MemoryContextReset(decompressor->per_compressed_row_ctx); decompressor->unprocessed_tuples = 0; decompressor->batches_decompressed = 0; decompressor->tuples_decompressed = 0; @@ -1805,8 +1806,6 @@ row_decompressor_decompress_row_to_table(RowDecompressor *decompressor) } MemoryContextSwitchTo(old_ctx); - MemoryContextReset(decompressor->per_compressed_row_ctx); - row_decompressor_reset(decompressor); return n_batch_rows; @@ -1826,8 +1825,6 @@ row_decompressor_decompress_row_to_tuplesort(RowDecompressor *decompressor, } MemoryContextSwitchTo(old_ctx); - MemoryContextReset(decompressor->per_compressed_row_ctx); - row_decompressor_reset(decompressor); }