jeremycole/innodb_ruby — pull request #20 by lefred (2014-04-09 12:51:01+00:00)
Title: dealing with orphaned tables

The change allows the tool to not stop with a stacktrace when there is a table/space in the data dictionary which is not present anymore on the filesystem.

How to reproduce:
- create a temporary table
- kill -9 mysqld_safe and mysqld (don't restart mysql)

Example before the patch:
---------------------------------
[root@percona ~]# innodb_space -s /var/lib/mysql/ibdata1 system-spaces
name pages indexes
(system) 768 6
mysql/gtid_slave_pos 6 1
mysql/innodb_index_stats 6 1
mysql/innodb_table_stats 6 1
test/t 6 1
/usr/local/share/gems/gems/innodb_ruby-0.9.7/lib/innodb/space.rb:26:in `initialize': No such file or directory - /var/lib/mysql/tmp/#sqlc2f_2_0.ibd (Errno::ENOENT)
from /usr/local/share/gems/gems/innodb_ruby-0.9.7/lib/innodb/space.rb:26:in `open'
from /usr/local/share/gems/gems/innodb_ruby-0.9.7/lib/innodb/space.rb:26:in `initialize'
from /usr/local/share/gems/gems/innodb_ruby-0.9.7/lib/innodb/system.rb:45:in `new'
from /usr/local/share/gems/gems/innodb_ruby-0.9.7/lib/innodb/system.rb:45:in `add_space_file'
from /usr/local/share/gems/gems/innodb_ruby-0.9.7/lib/innodb/system.rb:53:in `add_table'
from /usr/local/share/gems/gems/innodb_ruby-0.9.7/lib/innodb/system.rb:65:in `space'
from /usr/local/share/gems/gems/innodb_ruby-0.9.7/lib/innodb/system.rb:80:in `space_by_table_name'
from /usr/local/share/gems/gems/innodb_ruby-0.9.7/bin/innodb_space:177:in `block in system_spaces'
from /usr/local/share/gems/gems/innodb_ruby-0.9.7/lib/innodb/system.rb:90:in `block in each_table_name'
from /usr/local/share/gems/gems/innodb_ruby-0.9.7/lib/innodb/data_dictionary.rb:304:in `block in each_table'
from /usr/local/share/gems/gems/innodb_ruby-0.9.7/lib/innodb/data_dictionary.rb:291:in `block in each_record_from_data_dictionary_index'
from /usr/local/share/gems/gems/innodb_ruby-0.9.7/lib/innodb/index.rb:186:in `block (2 levels) in each_record'

And after:
------------
[root@percona ~]# innodb_space -s /var/lib/mysql/ibdata1 system-spaces
name pages indexes
(system) 768 6
mysql/gtid_slave_pos 6 1
mysql/innodb_index_stats 6 1
mysql/innodb_table_stats 6 1
test/t 6 1
(orphans)
/var/lib/mysql/tmp/#sqlc2f_2_0.ibd

Signed-off-by: fred