ddcw / ibd2sql

parse mysql ibd file to sql for learn or recovery data
GNU General Public License v3.0
155 stars 44 forks source link

error #36

Open rdugert opened 6 days ago

rdugert commented 6 days ago

I have an error with this ibd that might be corrupted. Any way to force or pass the error? Using --force does not change anything...

root@vip:~/ibd2sql# python3 main.py /var/lib/mysql.damaged/core/devcode.ibd --sql --ddl > devcode.sql Traceback (most recent call last): File "main.py", line 160, in ddcw.get_sql() File "/root/ibd2sql/ibd2sql/ibd2sql.py", line 231, in get_sql for x in _tdata: File "/root/ibd2sql/ibd2sql/innodb_page_index.py", line 246, in read_row self._read_all_row() File "/root/ibd2sql/ibd2sql/innodb_page_index.py", line 456, in _read_all_row _data[colno],_expage[colno] = self._read_field(col) File "/root/ibd2sql/ibd2sql/innodb_page_index.py", line 177, in _read_field _tdata = first_blob(self.f,PAGENO) File "/root/ibd2sql/ibd2sql/blob.py", line 9, in first_blob f.seek(pageno*16384,0) OSError: [Errno 22] Invalid argument

ddcw commented 6 days ago
  1. To determine if it is damaged, you can use this script(https://github.com/ddcw/ddcw/tree/master/python/check_innodb_file) for verification. Or instead of using --force, use --debug to known more.

  2. You can use the following method to force parsing. (bash)

    filename="/tmp/ddcw_alltype_table.ibd" # 要解析的ibd文件名
    python3 main.py ${filename} --ddl # 获取表结构信息
    filesize=`stat -c %s ${filename}`
    maxpagecount=$[ ${filesize} / 16384 ]
    current_page=1
    while [ ${current_page} -le ${maxpagecount} ];do
    echo "-- ${filename} PAGE NO: ${current_page}"; 
    current_page=$[ ${current_page} + 1 ]
    python3 main.py ${filename} --sql --page-start ${current_page} --page-count 1 2>/dev/null ; 
    done
  3. If there are no bad pages, you can use Alter table tablename import tablespace to import data