Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-68509

Deleting a temporary table forces a reload of the databasemeta cache (Backport of MDL-58584)

    XMLWordPrintable

    Details

      Description

      MDL-51374 introduced new behavior with temporary tables and the database cache; the creation and deletion of temporary tables isn't supposed to force a cache reload. This works on table creation but not deletion. The issue is that the temporary table is unlisted as such before the cache is reset, so the cache reset code doesn't know it was a temporary table and resets the whole cache. This leads to performance issues if you're running a job which creates and deletes numerous temporary tables, such as mass-creation of backups.

      This is the order of operations when deleting a temporary table:

      1. database_manager->drop_table()
        1. sql_generator->getDropTableSQL()
          1. moodle_temptables->delete_temptable()
        2. database_manager->execute_sql_arr()
          1. moodle_database->change_database_structure()
            1. moodle_database->reset_caches()

      To get the desired behavior I think the code in delete_temptable() needs to fire after the cache is reset. While examining my development environment I saw SHOW TABLE queries and column parsing after every backup and restore operation.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jan.dagefoerde Jan Dageförde
              Reporter:
              lucaboesch Luca Bösch
              Peer reviewer:
              Sam Marshall
              Integrator:
              Andrew Nicols
              Tester:
              CiBoT
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/May/20

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 20 minutes
                  20m