Skip to content

MDEV-34817: Performance schema is not cleared of removed package routines#4941

Open
kjarir wants to merge 1 commit intoMariaDB:10.11from
kjarir:MDEV-34817-fix-test-order
Open

MDEV-34817: Performance schema is not cleared of removed package routines#4941
kjarir wants to merge 1 commit intoMariaDB:10.11from
kjarir:MDEV-34817-fix-test-order

Conversation

@kjarir
Copy link
Copy Markdown
Contributor

@kjarir kjarir commented Apr 14, 2026

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

  1. In sp_drop_routine_internal: iterate sub-routines and call MYSQL_DROP_SP before removing the package from cache.
  2. In sp_drop_db_routines: use the thread's package body cache to identify and clear sub-routines when a package body is dropped during DROP DATABASE.

Testing

  • Added regression test: perfschema.mdev34817
  • Verified with: ./mtr --no-reorder compat/oracle.sp-package perfschema.lowercase_fs_off --repeat=5
  • Full perfschema suite passes

References

Closes MDEV-34817
Closes MDEV-35282

@kjarir kjarir force-pushed the MDEV-34817-fix-test-order branch from f8f310c to 4b18863 Compare April 14, 2026 17:59
@kjarir kjarir changed the title MDEV-34817: Fix Performance Schema not clearing package sub-routine stats on DROP DATABASE/DROP PACKAGE BODY MDEV-34817: perfschema.lowercase_fs_off fails on buildbot Apr 14, 2026
@grooverdan grooverdan self-assigned this Apr 15, 2026
@kjarir kjarir force-pushed the MDEV-34817-fix-test-order branch 3 times, most recently from a85b8f2 to 840d71d Compare April 15, 2026 14:50
@grooverdan grooverdan changed the title MDEV-34817: perfschema.lowercase_fs_off fails on buildbot MDEV-34817: Performance schema is not cleared of removed package routines Apr 15, 2026
Copy link
Copy Markdown
Member

@grooverdan grooverdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread mysql-test/suite/compat/oracle/t/perfschema.test
Comment thread mysql-test/suite/compat/oracle/t/perfschema.test Outdated
Comment thread sql/sp.cc
Comment thread sql/sp.cc
@grooverdan grooverdan added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Apr 15, 2026
@kjarir
Copy link
Copy Markdown
Contributor Author

kjarir commented Apr 16, 2026

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.

@kjarir kjarir force-pushed the MDEV-34817-fix-test-order branch 2 times, most recently from 140e66f to a2fa6a1 Compare April 16, 2026 04:01
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 16, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
9 out of 12 committers have signed the CLA.

✅ abhishek593
✅ gkodinov
✅ FaramosCZ
✅ spetrunia
✅ grooverdan
✅ mariadb-RexJohnston
✅ ParadoxV5
✅ kjarir
✅ HNOONa-0
❌ mariadb-YuchenPei
❌ montywi
❌ vuvova
You have signed the CLA already but the status is still pending? Let us recheck it.

@kjarir kjarir force-pushed the MDEV-34817-fix-test-order branch from a2fa6a1 to 4678182 Compare April 16, 2026 04:11
…ines

The Performance Schema table events_statements_summary_by_program was
retaining stale rows for package sub-routines after the parent package
or database was dropped. This caused regression tests like
perfschema.lowercase_fs_off to fail non-deterministically due to
unexpected ghost rows in the summary table.

The fix ensures that during DROP DATABASE and DROP PACKAGE BODY
operations, all associated package routines are properly identified
and removed from the Performance Schema instrumentation by abstracting
the PSI cleanup logic into a static helper function and invoking it
from both sp_drop_routine_internal and sp_drop_db_routines.
@kjarir kjarir force-pushed the MDEV-34817-fix-test-order branch from 4678182 to d43140a Compare April 16, 2026 06:36
@grooverdan grooverdan changed the base branch from 11.8 to 10.11 April 16, 2026 06:41
@grooverdan grooverdan self-requested a review April 16, 2026 07:13
Copy link
Copy Markdown
Member

@grooverdan grooverdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

4 participants