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

RENAME TABLE does not check for existence of the table's engine

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.5.33a, 10.0.6
    • Fix Version/s: 10.0.20
    • Component/s: Plugins
    • Labels:
    • Sprint:
      10.0.20

      Description

      When RENAME TABLE is executed, it apparently does not check whether the engine is available (unlike ALTER TABLE .. RENAME, which does). It means that if the engine in question was not loaded on some reason, the table might become unusable, since the engine won't know about the change.

      It was an upstream bug, which existed in previous versions as well, but it seems to be fixed in 5.7. Given how many engines we have and how easy it is to get this problem accidentally, maybe it makes sense to consider backporting the fix into 10.0.

      The test case below uses InnoDB to be universal for MariaDB and MySQL, so it looks a bit of a stretch. In reality, I encountered the problem with TokuDB, and it was really just a human error:

      • started the server with plugin-dir where ha_tokudb.so lived;
      • installed TokuDB engine;
      • created a TokuDB table;
      • then at some point I restarted the server, but with a different plugin-dir which did not have TokuDB;
      • since TokuDB is not a default engine or anything, server didn't have any problem starting;
      • I then renamed the table, which it did happily;
      • then I restarted the server again with the right plugin-dir, but TokuDB would not recognize the table any longer.

      Test case:

      
      --source include/have_innodb.inc
      
      create table t1 (i int) engine=InnoDB;
      
      --enable_reconnect
      
      --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
      wait
      EOF
      --shutdown_server 30
      --source include/wait_until_disconnected.inc
      
      --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
      restart: --skip-innodb --default-storage-engine=myisam --loose-default-tmp-storage-engine=myisam
      EOF
      
      --source include/wait_until_connected_again.inc
      
      rename table t1 to t2;
      
      --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
      wait
      EOF
      --shutdown_server 30
      --source include/wait_until_disconnected.inc
      --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
      restart
      EOF
      --source include/wait_until_connected_again.inc
      
      show tables;
      show create table t2;
      

      Fixing it is not that easy, simple reverse rename does not work, you have to repeat the whole exercise – start server without the engine, rename the table back, start server with the engine...

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              svoj Sergey Vojtovich added a comment -

              The problem is around since 2004. I can guess that it wasn't really intentional.

              revno: 1627.10.1
              revision-id: sp1r-serg@serg.mylan-20041021161058-05229
              parent: sp1r-serg@serg.mylan-20041020132603-06087
              committer: serg@serg.mylan
              timestamp: Thu 2004-10-21 18:10:58 +0200
              message:
                    smarter ALTER TABLE - don't copy the table if only comment or default values are changed
              
              Show
              svoj Sergey Vojtovich added a comment - The problem is around since 2004. I can guess that it wasn't really intentional. revno: 1627.10.1 revision-id: sp1r-serg@serg.mylan-20041021161058-05229 parent: sp1r-serg@serg.mylan-20041020132603-06087 committer: serg@serg.mylan timestamp: Thu 2004-10-21 18:10:58 +0200 message: smarter ALTER TABLE - don't copy the table if only comment or default values are changed
              Hide
              svoj Sergey Vojtovich added a comment -

              Sergei Golubchik, please review fix for this bug.

              Show
              svoj Sergey Vojtovich added a comment - Sergei Golubchik , please review fix for this bug.
              Hide
              svoj Sergey Vojtovich added a comment -

              Sergei Golubchik, please review updated fix.

              Show
              svoj Sergey Vojtovich added a comment - Sergei Golubchik , please review updated fix.

                People

                • Assignee:
                  svoj Sergey Vojtovich
                  Reporter:
                  elenst Elena Stepanova
                • Votes:
                  1 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Time Tracking

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

                      Agile