MDEV-34817: Performance schema is not cleared of removed package routines#4941
MDEV-34817: Performance schema is not cleared of removed package routines#4941kjarir wants to merge 1 commit intoMariaDB:10.11from
Conversation
f8f310c to
4b18863
Compare
a85b8f2 to
840d71d
Compare
There was a problem hiding this comment.
As 10.11 is affected too, sorry it wasn't obvious on the bug, back port this to there. Note a few variable constructs are different, but the compiler will find them.
There's a test case for DROP DATABASE, but as your implementation highlights, DROP PACKAGE/ DROP PACKAGE BODY are also affected. Just testing one of these is sufficient as both end up in sp_drop_routine_internal.
Lastly, the improved commit message header is better than the previous MDEV title. But I think the title I rename this PR is clearer again so please use that. There should be a body in the commit message describing the problem and correction.
|
Thanks for the detailed review @grooverdan. Working through all the points now, will push an updated version shortly with the static helper, improved test formatting, DROP PACKAGE test case, and updated commit message. |
140e66f to
a2fa6a1
Compare
4678182 to
d43140a
Compare
grooverdan
left a comment
There was a problem hiding this comment.
Its currently failing on embedded tests.
--- /home/buildbot/amd64-debian-11-debug-ps-embedded/build/mysql-test/suite/compat/oracle/r/perfschema.result 2026-04-16 06:40:34.000000000 +0000
+++ /home/buildbot/amd64-debian-11-debug-ps-embedded/build/mysql-test/suite/compat/oracle/r/perfschema.reject 2026-04-16 06:45:26.326364209 +0000
@@ -40,7 +40,6 @@
FROM performance_schema.events_statements_summary_by_program
WHERE LOWER(object_schema)='mdev34817_db';
object_type object_schema object_name
- mdev34817_db pkg1
DROP DATABASE mdev34817_db;
I suspect that a --source include/not_embedded.inc might be needed as many of mysql-test/suite/compat/oracle/t around stored procedures already do. I'm going to leave this as a call to the second reviewer so no need to address this immediately.
| @@ -1104,6 +1104,35 @@ sp_returns_type(THD *thd, String &result, const sp_head *sp) | |||
| used to indicate about errors. | |||
| */ | |||
There was a problem hiding this comment.
this is description of function Sp_handler::sp_drop_routine_internal, please move this to its correct place, right above the function body.
There was a problem hiding this comment.
Good catch, thanks! I'll move the description block to its correct place right above the Sp_handler::sp_drop_routine_internal function body.
| @param spc The cache to look up the package body. | ||
| @param name The package body name. | ||
| */ | ||
| static void sp_psi_drop_package_routines(sp_cache **spc, |
There was a problem hiding this comment.
sp_cache is thread-local. what should happen in this scenario?
- in connection-1, I create a
db&pkgand call -call db.pkg.p1() - in connection-2, I drop the db.
sp_psi_drop_package_routinesfinds nothing in thesp_cache. - switch to connection-1 and query perfschema, the row is still there.
connect (con1, localhost, root,,);
connect (con2, localhost, root,,);
connection con1;
SET sql_mode=ORACLE;
CREATE DATABASE mdev34817_db;
DELIMITER $$;
CREATE PACKAGE mdev34817_db.pkg1 AS
PROCEDURE p1();
END;
$$
CREATE PACKAGE BODY mdev34817_db.pkg1 AS
PROCEDURE p1() AS
BEGIN
NULL;
END;
END;
$$
DELIMITER ;$$
CALL mdev34817_db.pkg1.p1();
connection con2;
--echo # Testing DROP DATABASE
DROP DATABASE mdev34817_db;
connection con1;
SELECT object_type, object_schema, object_name
FROM performance_schema.events_statements_summary_by_program
WHERE LOWER(object_schema)='mdev34817_db';out-
CALL mdev34817_db.pkg1.p1();
+connection con2;
# Testing DROP DATABASE
DROP DATABASE mdev34817_db;
+connection con1;
SELECT object_type, object_schema, object_name
FROM performance_schema.events_statements_summary_by_program
WHERE LOWER(object_schema)='mdev34817_db';
object_type object_schema object_name
+PROCEDURE mdev34817_db pkg1.p1
There was a problem hiding this comment.
You're right since sp_cache is thread-local, if the dropping connection never loaded the package, the cache will be empty and PSI cleanup will be silently skipped. The fix needs to read the sub-routine names directly from mysql.proc instead of relying on the cache, similar to how sp_drop_db_routines already iterates the table. I'll rework the approach accordingly.
| @@ -0,0 +1,66 @@ | |||
| --echo # | |||
There was a problem hiding this comment.
I'd recommend adding these two-
--source include/not_embedded.inc
--source include/have_perfschema.incThere was a problem hiding this comment.
Good point, I'll add both include/not_embedded.inc and include/have_perfschema.inc at the top of the test.
d43140a to
2979f0f
Compare
2979f0f to
f408493
Compare
Problem
When DROP DATABASE or DROP PACKAGE BODY is executed, sp_drop_db_routines() was not calling MYSQL_DROP_SP for Oracle-style package body sub-routines. This caused stale ghost rows to remain in events_statements_summary_by_program, making the MTR test perfschema.lowercase_fs_off fail non-deterministically when run after compat/oracle.sp-package.
Fix
Testing
References
Closes MDEV-34817
Closes MDEV-35282