Shard-Query blog

The only open source MPP database engine for MySQL

Fix for INFORMATION_SCHEMA.PARTITIONS losing table stats

Here is a fix for the MySQL/TokuDB/MariaDB bug I reported earlier today.  I think this fix is correct (it is only one line) but I don’t delve into the storage engine very often (and particularly not into ha_partition.cc) so I think it would be good to wait for Oracle (or Percona, MariaDB, or Tokutek) to validate that it is correct before using it.

diff -u ha_partition.cc /tmp/ha_partition.cc 
--- ha_partition.cc 2013-04-05 05:27:18.000000000 -0700
+++ /tmp/ha_partition.cc 2013-05-27 02:45:01.680676228 -0700
@@ -6455,9 +6455,11 @@
void ha_partition::get_dynamic_partition_info(PARTITION_STATS *stat_info,
uint part_id)
{
+
handler *file= m_file[part_id];
DBUG_ASSERT(bitmap_is_set(&(m_part_info->read_partitions), part_id));
- file->info(HA_STATUS_CONST | HA_STATUS_TIME | HA_STATUS_VARIABLE |
+ 
+ info(HA_STATUS_CONST | HA_STATUS_TIME | HA_STATUS_VARIABLE |
HA_STATUS_VARIABLE_EXTRA | HA_STATUS_NO_LOCK);
stat_info->records= file->stats.records;

3 responses to “Fix for INFORMATION_SCHEMA.PARTITIONS losing table stats

  1. Mikael Ronström May 31, 2013 at 2:45 AM

    Must admit that I fail to see any change in the patch at all, two new empty lines and a change of the info call to what it is already is in the code??

  2. Justin May 31, 2013 at 11:01 AM

    i changed file->info (which set the HA information on the partition) to info() which calls it on the table. I don’t think it is correct, but it fixed the problem for me. The problem is that I_S.partitions calls get_dynamic_partition_info() in a loop, and it ends up pinning the stats from the last partition as stats for all partitions. It needs to take the stats from the most populous partition, or something like that.

    • Justin May 31, 2013 at 11:11 AM

      I may have just done something terrible and corrupted memory, etc. I didn’t run the test suite after the change (stupid) but I wanted to let people know that I found, at least, the function with the problem which is get_dynamic_partition_info().

      I really try to stay to high level languages and I haven’t touched C++ since HS. Just looking at the code and figuring out the scope of various variables took a bit because I’m not familiar with the classes being used.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 162 other followers

%d bloggers like this: