1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-31893 Valgrind reports issues in main.join_cache_notasan

This is also related to
MDEV-31348 Assertion `last_key_entry >= end_pos' failed in virtual bool
           JOIN_CACHE_HASHED::put_record()

Valgrind exposed a problem with the join_cache for hash joins:
=25636== Conditional jump or move depends on uninitialised value(s)
==25636== at 0xA8FF4E: JOIN_CACHE_HASHED::init_hash_table()
          (sql_join_cache.cc:2901)

The reason for this was that avg_record_length contained a random value
if one had used SET optimizer_switch='optimize_join_buffer_size=off'.

This causes either 'random size' memory to be allocated (up to
join_buffer_size) which can increase memory usage or, if avg_record_length
is less than the row size, memory overwrites in thd->mem_root, which is
bad.

Fixed by setting avg_record_length in JOIN_CACHE_HASHED::init()
before it's used.

There is no test case for MDEV-31893 as valgrind of join_cache_notasan
checks that.
I added a test case for MDEV-31348.
This commit is contained in:
Monty
2023-08-10 16:13:32 +03:00
committed by Oleksandr Byelkin
parent 0ede90dd31
commit 2aea938749
6 changed files with 70 additions and 11 deletions

View File

@ -6256,3 +6256,19 @@ length(concat(t1.f,t2.f))
DROP TABLE t;
set @@optimizer_switch=@org_optimizer_switch;
set @@join_buffer_size=@org_join_buffer_size;
#
# MDEV-31348 Assertion `last_key_entry >= end_pos' failed in
# virtual bool JOIN_CACHE_HASHED::put_record()
#
SET JOIN_buffer_size=1;
Warnings:
Warning 1292 Truncated incorrect join_buffer_size value: '1'
SET SESSION JOIN_cache_level=4;
SET SESSION optimizer_switch='optimize_JOIN_buffer_size=OFF';
SELECT * FROM information_schema.statistics JOIN information_schema.COLUMNS USING (table_name,column_name);
ERROR HY001: Could not create a join buffer. Please check and adjust the value of the variables 'JOIN_BUFFER_SIZE (128)' and 'JOIN_BUFFER_SPACE_LIMIT (2097152)'
SET JOIN_buffer_size=16384;
SELECT * FROM information_schema.statistics JOIN information_schema.COLUMNS USING (table_name,column_name);
#
# End of 10.4 tests
#