Skip to content
This repository has been archived by the owner on Jun 12, 2020. It is now read-only.

Dynamic plugins

prohaska edited this page Oct 7, 2014 · 5 revisions

Dynamic plugins do not work in MySQL. For example, when a table is dropped, MySQL will not inform the storage engine if the dynamic plugin number assigned to a storage engine changes. Here is how to reproduce the problem.

Step 1. Hack the example storage engine to create a file for each table and to unlink the file when the table is deleted.

$ diff ha_example.cc ~/Downloads/mysql-5.6.21/storage/example
836,839d835
<   int r = ::unlink(name);
<   if (r == -1)
<       r = errno;
<   assert(r == 0);
913,915d908
<   int fd = ::creat(name, 0777);
<   assert(fd != -1);
<   ::close(fd);

Step 2. Startup MySQL and install the example storage engine.

Step 3. Create a table s.

create table test.s (id int) engine=example;

There should be a file s.frm and a file s in the test directory.

Step 4. Drop table s. All of the files in the test directory are removed.

Step 5. Create another table t.

create table test.t (id int) engine=example;

There should be a file t.frm and a file t in the test directory.

Step 6. Shutdown MySQL

Step 7. Change the plugin number in the t.frm file from 42 to 43. 42 is the plugin number that is stored in byte 3 of the frm file. This can happen if the sequence of dynamic plugins that are installed changes.

$ hexdump -C t.frm
00000000  fe 01 09 2a 03 00 00 10  01 00 00 30 00 00 10 00  |...*.......0....|
00000010  05 00 00 00 00 00 00 00  00 00 00 02 08 00 08 00  |................|
00000020  00 05 00 00 00 00 08 00  00 00 00 00 00 00 00 10  |................|
00000030  00 00 00 bd c5 00 00 1b  00 00 00 00 00 00 00 00  |................|
00000040  2f 2f 00 00 20 00 00 00  00 00 00 00 00 00 00 00  |//.. ...........|
00000050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00001000  00 00 00 00 02 00 ff 00  00 00 00 00 00 00 00 00  |................|
00001010  ff 00 00 00 00 00 00 07  00 45 58 41 4d 50 4c 45  |.........EXAMPLE|

Step 8. Start MySQL

Step 9. Drop table t.

Problem: MySQL does not call the example storage engine's delete_table handler method, so the files managed by the example storage engine are NOT cleaned up.

Clone this wiki locally