Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-35282

Performance schema does not clear package routines

Details

    Description

      This MTR test:

      --source include/default_charset.inc
       
      SET sql_mode=ORACLE;
      CREATE DATABASE db1;
      DELIMITER $$;
      CREATE PACKAGE db1.pkg1 AS
        PROCEDURE p1();
      END;
      $$
       
      CREATE PACKAGE BODY db1.pkg1 AS
      PROCEDURE p1() AS
        BEGIN
          NULL;
        END;
      END;
      $$
       
      DELIMITER ;$$
       
      CALL db1.pkg1.p1();
       
      DROP DATABASE db1;
       
       
      SELECT object_type, object_schema, object_name
      FROM performance_schema.events_statements_summary_by_program
       WHERE object_type='procedure' AND LOWER(object_schema)='db1';
      

      prints the following output:

      object_type	object_schema	object_name
      PROCEDURE	db1	pkg1.p1
      

      Notice, the database db1 is already dropped. So the statistics should not contain information about its objects.

      Attachments

        Issue Links

          Activity

            The problem happens because when a package procedure (or a package function) is executed, performance schema remembers it as:

            type='procedure'
            db='db'
            name='pkg1.p1'
            

            When a DROP DATABASE happens, performance schema removes from its cached only a record like this:

            type='package body'
            db='db'
            name='pkg1'
            

            To make it work properly, when removing a package body from the perfschema cache, it should parse the package body and remove its all routines.
            This looks quite complex.

            Another option is to remember package routines in perfschema as their owner package body. So when db.pkg1.p1 is executed, perfschema remembers it as:

            type='package body'
            db='db'
            name='pkg1'
            

            But this will worsen the statistics.

            bar Alexander Barkov added a comment - The problem happens because when a package procedure (or a package function) is executed, performance schema remembers it as: type='procedure' db='db' name='pkg1.p1' When a DROP DATABASE happens, performance schema removes from its cached only a record like this: type='package body' db='db' name='pkg1' To make it work properly, when removing a package body from the perfschema cache, it should parse the package body and remove its all routines. This looks quite complex. Another option is to remember package routines in perfschema as their owner package body. So when db.pkg1.p1 is executed, perfschema remembers it as: type='package body' db='db' name='pkg1' But this will worsen the statistics.

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.