mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
724a5105cb
Problem: push_handler() created sp_handler_entry instances on THD::main_mem_root, which is freed only after the SP instructions execution. So in case of a CONTINUE HANDLER inside a loop (e.g. WHILE) this approach leaked thread memory on every loop iteration. Changes: - Removing sp_handler_entry declaration, it's not really needed. - Fixing the data type of sp_rcontext::m_handlers from Dynamic_array<sp_handler_entry*> to Dynamic_array<sp_instr_hpush_jump*> - Fixing sp_rcontext::push_handler() to push the pointer to an sp_instr_hpush_jump instance to the handler stack. This instance contains everything we need. There is no a need to allocate anything else.
50 lines
1.5 KiB
Text
50 lines
1.5 KiB
Text
|
|
--echo #
|
|
--echo # Start of 10.3 tests
|
|
--echo #
|
|
|
|
--echo #
|
|
--echo # MDEV-16595 SP with a CONTINUE HANDLER inside a loop wastes THD memory aggressively
|
|
--echo #
|
|
|
|
DELIMITER $$;
|
|
CREATE PROCEDURE p1()
|
|
BEGIN
|
|
DECLARE mem_used_old BIGINT UNSIGNED DEFAULT
|
|
(SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS
|
|
WHERE VARIABLE_NAME='MEMORY_USED');
|
|
DECLARE i INT DEFAULT 1;
|
|
WHILE i <= 1000
|
|
DO
|
|
BEGIN
|
|
DECLARE msg TEXT;
|
|
DECLARE mem_used_cur BIGINT UNSIGNED DEFAULT
|
|
(SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS
|
|
WHERE VARIABLE_NAME='MEMORY_USED');
|
|
DECLARE CONTINUE HANDLER FOR SQLSTATE '23000' SET @x=1;
|
|
DECLARE CONTINUE HANDLER FOR SQLSTATE '23001' SET @x=1;
|
|
DECLARE CONTINUE HANDLER FOR SQLSTATE '23002' SET @x=1;
|
|
DECLARE CONTINUE HANDLER FOR SQLSTATE '23003' SET @x=1;
|
|
DECLARE CONTINUE HANDLER FOR SQLSTATE '23004' SET @x=1;
|
|
DECLARE CONTINUE HANDLER FOR SQLSTATE '23005' SET @x=1;
|
|
DECLARE CONTINUE HANDLER FOR SQLSTATE '23006' SET @x=1;
|
|
DECLARE CONTINUE HANDLER FOR SQLSTATE '23007' SET @x=1;
|
|
DECLARE CONTINUE HANDLER FOR SQLSTATE '23008' SET @x=1;
|
|
IF (mem_used_cur >= mem_used_old * 1.1) THEN
|
|
SHOW STATUS LIKE 'Memory_used';
|
|
SET msg=CONCAT('Memory leak detected: i=', i, ' mem_used_old=',mem_used_old,' mem_used_cur=', mem_used_cur);
|
|
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT=msg;
|
|
END IF;
|
|
END;
|
|
SET i=i+1;
|
|
END WHILE;
|
|
END;
|
|
$$
|
|
DELIMITER ;$$
|
|
CALL p1;
|
|
DROP PROCEDURE p1;
|
|
|
|
|
|
--echo #
|
|
--echo # End of 10.3 tests
|
|
--echo #
|