MDEV-30603: Wrong result with non-default JOIN_CACHE_LEVEL=[4|5] ...
JOIN_CACHE::alloc_buffer() used wrong logic when calculating the size of all join buffers. Then, it computed the ratio by which JOIN::shrink_join_buffers() should shrink the buffers. shrink_join_buffers() ended up in a situation where buffers would not fit into the total quota after shrinking, which resulted in negative buffer sizes. Due to use of unsigned integers it would cause very large buffers to be used instead. Make JOIN_CACHE::alloc_buffer() use the same logic as JOIN::shrink_join_buffers() when it calculates the total size of all join buffers so far. Also, add a safety check in JOIN::shrink_join_buffers() This patch doesn't include a testcase, because the original test dataset is too big and fragile. We have dbt3_s001.inc but I wasn't able to demonstrate the issue with it.
Showing
Please register or sign in to comment