BUG/MEDIUM: chunk: make sure to flush the trash pool before resizing
authorWilly Tarreau <w@1wt.eu>
Wed, 29 Jan 2025 16:51:12 +0000 (17:51 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 19 Feb 2025 10:38:51 +0000 (11:38 +0100)
commita719b90b565a58b3149d2cc4f355d446bc9f727c
treec62695445fdb55a85a3b769317f8e62353b0c65e
parentcf4d3fc9aec7bb16191cad2678554b631553a99d
BUG/MEDIUM: chunk: make sure to flush the trash pool before resizing

Late in 3.1 we've added an integrity check to make sure we didn't keep
trash objects allocated before resizing the trash with commit 0bfd36e7b8
("MINOR: chunk: add a BUG_ON upon the next init_trash_buffer()"), but
it turns out that the counter that is being checked includes the number
of objects left in local thread caches. As such it can trigger despite
no object being allocated. This precisely happens when setting
tune.memory.hot-size to a few megabytes because some temporarily used
trash objects will remain in cache.

In order to address this, let's first flush the pool before running
the check. That was previously done by pool_destroy() but the check
had to be inserted before it. So now we first flush the trash pool,
then verify it's no longer used, and finally we can destroy it.

This needs to be backported to 3.1. Thanks to Christian Ruppert for
reporting this bug.

(cherry picked from commit bd7a688b8b38901037cd2f9856533a788ebdbdf7)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/chunk.c