Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

大佬,求助 #38

Open
ssw0309 opened this issue Sep 24, 2024 · 59 comments
Open

大佬,求助 #38

ssw0309 opened this issue Sep 24, 2024 · 59 comments

Comments

@ssw0309
Copy link

ssw0309 commented Sep 24, 2024

运行时,遇到这个错误:struct.error: unpack requires a buffer of 20 bytes

@ssw0309
Copy link
Author

ssw0309 commented Sep 24, 2024

Uploading a.png…

@ddcw
Copy link
Owner

ddcw commented Sep 24, 2024

看不到图片... 从报错来看,应该是存在lob类型解析失败. 请提供下ibd2sql的版本. 和报错详情.

最好是使用最新版的ibd2sql

@ssw0309
Copy link
Author

ssw0309 commented Sep 24, 2024

版本 ibd2sql VERSION: v1.5 for MySQL 5.7 or 8.0
具体抱错类型:
Traceback (most recent call last):
File "/home/study/ibd2sql-main/main.py", line 160, in
ddcw.get_sql()
File "/home/study/ibd2sql-main/ibd2sql/ibd2sql.py", line 237, in get_sql
for x in _tdata:
File "/home/study/ibd2sql-main/ibd2sql/innodb_page_index.py", line 246, in read_row
self._read_all_row()
File "/home/study/ibd2sql-main/ibd2sql/innodb_page_index.py", line 458, in _read_all_row
_data[colno],_expage[colno] = self._read_field(col)
^^^^^^^^^^^^^^^^^^^^^
File "/home/study/ibd2sql-main/ibd2sql/innodb_page_index.py", line 177, in _read_field
_tdata = first_blob(self.f,PAGENO)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/study/ibd2sql-main/ibd2sql/blob.py", line 9, in first_blob
f.seek(pageno*16384,0)
OSError: [Errno 22] Invalid argument

@ssw0309
Copy link
Author

ssw0309 commented Sep 24, 2024

按照1.6版本下载。 提示还是1.5的版本信息

@ddcw
Copy link
Owner

ddcw commented Sep 25, 2024

  1. 版本显示问题, 是我忘记修改版本号了 -_-...
  2. 从报错来看是解析blob数据类型的时候报错(应该是pageno有问题.), 大概率是坏块, 可以使用https://github.com/ddcw/ddcw/tree/master/python/check_innodb_file 检查下是否存在坏块. 如果存在, 请参考 https://github.com/ddcw/ibd2sql/blob/main/docs/USAGE.md 中ibd文件损坏的场景解析.

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

按照你的方法试了 运行check_innodb_file 没有提示抱错

@ddcw
Copy link
Owner

ddcw commented Sep 25, 2024

没有报错那就是没有坏块的意思. 那就说明是这个脚本的BUG了. 执行的时候加上--debug看下具体信息呢

python3 main.py xxx.ibd --ddl --sql --limit 1 --debug

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

取1条正常执行 ,这个是取多条抱错了
[2024-09-25 13:53:29] [DEBUG] 20 bytes ON BOTH SIDES OF RECORD, b'\x01\x00\x02\x0f\x06\x08\x02\x0c\x0c\x08\x02\x0b\x12\t\x13\x0c\x90v\x00\x00', b'\x00\x01@\x01N\x98\xc7M\xc0M\xc1\x00\x01\x00\x00\x07]cW\x02'
[2024-09-25 13:53:29] [DEBUG] READ NULL BITMASK
[2024-09-25 13:53:29] [DEBUG] NULLABLE FILED COUNT: 36 NULLABLE FIELD COUNT(FOR INSTANT):6
[2024-09-25 13:53:29] [DEBUG] NULL BITMASK: COUNT:42 ID: 20944684187648 [0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[2024-09-25 13:53:29] [DEBUG] READ KEY FILED
[2024-09-25 13:53:29] [DEBUG] READ KEY COLNO:1 NAME:id
[2024-09-25 13:53:29] [DEBUG] 13771 ----> 13779 data:1785481265609244673 bdata:b'\x98\xc7M\xc0M\xc1\x00\x01'
[2024-09-25 13:53:29] [DEBUG] READ KEY NO:1 NAME:id FINISH. VALUES: 1785481265609244673
[2024-09-25 13:53:29] [DEBUG] READ TRX(6) AND ROLLPTR(7) INFO
[2024-09-25 13:53:29] [DEBUG] TRX: 123560791 ROLLPTR: 562949964180249
[2024-09-25 13:53:29] [DEBUG] ROW VERSION : -1
[2024-09-25 13:53:29] [DEBUG] INSTANT FLAG : False
[2024-09-25 13:53:29] [DEBUG] ROW VERSION FLAG : False
[2024-09-25 13:53:29] [DEBUG] NAME: account VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] 13792 ----> 13801 data:621663600 bdata:b'621663600'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: account_name VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] BLOB ERROR 'utf-8' codec can't decode bytes in position 16-17: unexpected end of data
[2024-09-25 13:53:29] [DEBUG] 13801 ----> 13819 data:0x31303031303731383234e99fa9e5a29ee697 bdata:b'1001071824\xe9\x9f\xa9\xe5\xa2\x9e\xe6\x97'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: id_card VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] BLOB ERROR 'utf-8' codec can't decode byte 0xad in position 0: invalid start byte
[2024-09-25 13:53:29] [DEBUG] 13819 ----> 13830 data:0xad33373039313132303035 bdata:b'\xad3709112005'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: phone VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] 13830 ----> 13832 data:01 bdata:b'01'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: push_status VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] 13832 ----> 13840 data:31241518 bdata:b'31241518'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: push_number VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] 13840 ----> 13844 data:-1254803913 bdata:b'5567'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: transfer_out_time VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] 13844 ----> 13849 data:-4504-12-25 3:28:52 bdata:b'91274'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: transfer_out_amount VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] 13849 ----> 13857 data:-3.889992269640005e-60 bdata:b'1 \x80\x00\x00\x01\x99\xb3'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: bank_name_flag VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] BLOB ERROR 'utf-8' codec can't decode byte 0x84 in position 8: invalid start byte
[2024-09-25 13:53:29] [DEBUG] 13857 ----> 13869 data:0x420207000000000084b74031 bdata:b'B\x02\x07\x00\x00\x00\x00\x00\x84\xb7@1'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: bank_name VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] BLOB ERROR 'utf-8' codec can't decode bytes in position 10-11: unexpected end of data
[2024-09-25 13:53:29] [DEBUG] 13869 ----> 13881 data:0x20202020202020e4b8ade59b bdata:b' \xe4\xb8\xad\xe5\x9b'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: bank_id VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] BLOB ERROR 'utf-8' codec can't decode byte 0xbd in position 0: invalid start byte
[2024-09-25 13:53:29] [DEBUG] 13881 ----> 13883 data:0xbde9 bdata:b'\xbd\xe9'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: source VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] BLOB ERROR 'utf-8' codec can't decode byte 0x93 in position 0: invalid start byte
[2024-09-25 13:53:29] [DEBUG] 13883 ----> 13891 data:0x93b6e8a18c313034 bdata:b'\x93\xb6\xe8\xa1\x8c104'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: fraud_type VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] 13891 ----> 13897 data:100000 bdata:b'100000'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: fraud_name VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] BLOB ERROR 'utf-8' codec can't decode bytes in position 13-14: unexpected end of data
[2024-09-25 13:53:29] [DEBUG] 13897 ----> 13912 data:0x30303431203132303720202020e585 bdata:b'0041 1207 \xe5\x85'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: reason VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] BLOB ERROR 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
[2024-09-25 13:53:29] [DEBUG] 13912 ----> 13914 data:0xb6e4 bdata:b'\xb6\xe4'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: status VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] 13914 ----> 13914 data: bdata:b''
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: file_address VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] BLOB ERROR 'utf-8' codec can't decode byte 0xbb in position 0: invalid start byte
[2024-09-25 13:53:29] [DEBUG] 13914 ----> 13915 data:0xbb bdata:b'\xbb'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: failure_reason VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] BLOB ERROR 'utf-8' codec can't decode byte 0x96 in position 0: invalid start byte
[2024-09-25 13:53:29] [DEBUG] 13915 ----> 13917 data:0x96e4 bdata:b'\x96\xe4'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: stop_payment_flag VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] BLOB ERROR 'utf-8' codec can't decode byte 0xbf in position 0: invalid start byte
[2024-09-25 13:53:29] [DEBUG] 13917 ----> 13919 data:0xbf9d bdata:b'\xbf\x9d'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: stop_payment_type VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] 13919 ----> 13938 data:护性止付6 -1 1 bdata:b'\xe6\x8a\xa4\xe6\x80\xa7\xe6\xad\xa2\xe4\xbb\x986 -1 1 '
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: dept_id VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] 13938 ----> 13956 data:174281928137827123 bdata:b'174281928137827123'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: dept_name VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] BLOB ERROR 'utf-8' codec can't decode byte 0x80 in position 19: invalid start byte
[2024-09-25 13:53:29] [DEBUG] 13956 ----> 13992 data:0x34e5a682e79a8be5b882e585ace5ae89e5b1808000000f30313031413130303239313132 bdata:b'4\xe5\xa6\x82\xe7\x9a\x8b\xe5\xb8\x82\xe5\x85\xac\xe5\xae\x89\xe5\xb1\x80\x80\x00\x00\x0f0101A10029112'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: stop_number VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] 13992 ----> 13996 data:-1322043597 bdata:b'1373'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: register_id VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 7 ########
[2024-09-25 13:53:29] [DEBUG] NAME: early_id VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 7 ########
[2024-09-25 13:53:29] [DEBUG] NAME: application_id VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] 13996 ----> 14012 data:8632FZ2405010929 bdata:b'8632FZ2405010929'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: is_extend_stop VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 7 ########
[2024-09-25 13:53:29] [DEBUG] NAME: card_level VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 7 ########
[2024-09-25 13:53:29] [DEBUG] NAME: account_type VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 7 ########
[2024-09-25 13:53:29] [DEBUG] NAME: submit_time VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] 14012 ----> 14017 data:-3795-9-24 9:38:51 bdata:b'000\x99\xb3'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: push_time VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] 14017 ----> 14022 data:-5245-3-3 25:38:51 bdata:b'B\x97\x07\x99\xb3'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: create_time VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] 14022 ----> 14027 data:-5245-3-6 9:38:51 bdata:b'B\x97\x0c\x99\xb3'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: institution_return_time VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] 14027 ----> 14032 data:-5245-3-0 25:38:51 bdata:b'B\x97\x01\x99\xb3'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: next_submit_time VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] 14032 ----> 14037 data:-5250-7-24 9:38:51 bdata:b'B\xa8p\x99\xb3'
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: batch_no VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 7 ########
[2024-09-25 13:53:29] [DEBUG] NAME: submit_type VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] BLOB ERROR 'utf-8' codec can't decode byte 0x97 in position 1: invalid start byte
[2024-09-25 13:53:29] [DEBUG] 14037 ----> 14044 data:0x4697c631202020 bdata:b'F\x97\xc61 '
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: stop_time VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] 14044 ----> 14049 data:-2530-6-16 2:0:32 bdata:b' '
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: fund_id VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 7 ########
[2024-09-25 13:53:29] [DEBUG] NAME: stop_time_gf VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] 14049 ----> 14054 data:-2530-6-16 2:0:32 bdata:b' '
[2024-09-25 13:53:29] [DEBUG] ######## DDCW FLAG 8 ########
[2024-09-25 13:53:29] [DEBUG] NAME: yue_gf VERSION_ADDED:0 VERSION_DROPED:0 COL_INSTANT:False ROW VERSION:-1
[2024-09-25 13:53:29] [DEBUG] VARCHAR: SPACE_ID:539007411 PAGENO:1620509081 BLOB_HEADER:3007485894 REAL_SIZE:3689068452078039809
Traceback (most recent call last):
File "/home/study/1bd16/ibd2sql-1.6/main.py", line 160, in
ddcw.get_sql()
File "/home/study/1bd16/ibd2sql-1.6/ibd2sql/ibd2sql.py", line 231, in get_sql
for x in _tdata:
File "/home/study/1bd16/ibd2sql-1.6/ibd2sql/innodb_page_index.py", line 246, in read_row
self._read_all_row()
File "/home/study/1bd16/ibd2sql-1.6/ibd2sql/innodb_page_index.py", line 458, in _read_all_row
_data[colno],_expage[colno] = self._read_field(col)
^^^^^^^^^^^^^^^^^^^^^
File "/home/study/1bd16/ibd2sql-1.6/ibd2sql/innodb_page_index.py", line 177, in _read_field
_tdata = first_blob(self.f,PAGENO)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/study/1bd16/ibd2sql-1.6/ibd2sql/blob.py", line 9, in first_blob
f.seek(pageno*16384,0)
OSError: [Errno 22] Invalid argument

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

大佬,方便加一下联系方式吗?不太好发图片

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

a

@ddcw
Copy link
Owner

ddcw commented Sep 25, 2024

不太方便提供联系方式呢.(不安全).... 从报错来看, 元数据信息是乱的(account_name 能是blob类型?). 这是5.7的数据文件吗? 8.0的数据文件就在ibd文件里面, 没得坏块的话,基本上不存在有问题的. 或者就是脚本有问题.(但这个版本已经修复了8.0: instant的BUG了)

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

这个是8.0.13免安装版本的
account_anme不是varchar的

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

a 解析ddl可以 解析sql会报错

@ddcw
Copy link
Owner

ddcw commented Sep 25, 2024

8.0.13 是在测试范围内的版本.
报错显示的BLOB ERROR位于ibd2sql/innodb_page_index.py文件中, 当col['is_big']为True时,才会走这个逻辑. 但varchar不属于is_big啊. (只有lob,json,geom,vector才有这个属性.)
也就是: 实际上最开始几行也应该是错误的解析, 但blob不一定有溢出页,所以也是能解析的. 但其它情况就会报错了. 你看下最开始的debug信息呢, 那里面有每个字段是否有is_big的

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

1

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

会不会是 varchar里面包含特殊字符,或者内容特别长?

@ddcw
Copy link
Owner

ddcw commented Sep 25, 2024

应该不会是特殊字符. 编码问题之前也已经解决了的(目前支持ascii和utf8)
还在上面一点, 大概如下这个样子:

[2024-09-25 14:35:47] [DEBUG] OPEN IBD FILE: /data/mysql_3314/mysqldata/ibd2sql/ddcw_alltype_table.ibd
[2024-09-25 14:35:47] [DEBUG] ANALYZE FIRST PAGE: FIL_PAGE_TYPE_FSP_HDR
[2024-09-25 14:35:47] [DEBUG] ibd2sql.read PAGE: 0 
[2024-09-25 14:35:47] [DEBUG] ANALYZE FIRST PAGE FINISH
[2024-09-25 14:35:47] [DEBUG] SDI PAGE NO: 3
[2024-09-25 14:35:47] [DEBUG] ANALYZE SDI PAGE
[2024-09-25 14:35:47] [DEBUG] ibd2sql.read PAGE: 3 
[2024-09-25 14:35:47] [DEBUG] ANALYZE SDI PAGE FINISH
[2024-09-25 14:35:47] [DEBUG] SET ibd2sql.table = sdi.table (SDI的使命已结束 >_<)
[2024-09-25 14:35:47] [DEBUG] META INFO
[2024-09-25 14:35:47] [DEBUG] COLNO: 1  
{'name': 'id', 'is_autoincrement': True, 'type': 'int', 'isvar': False, 'size': 4, 'isbig': False, 'elements_dict': {}, 'varsi
ze': 0, 'have_default': False, 'default': '', 'comment': '', 'collation': 'latin1_swedish_ci', 'character_set': 'latin1', 'ind
ex_type': 'PK', 'is_nullable': False, 'is_zerofill': False, 'is_unsigned': False, 'is_auto_increment': True, 'is_virtual': Fal
se, 'hidden': 1, 'char_length': 11, 'extra': None, 'instant': False, 'instant_value': '', 'instant_null': True, 'generation_ex
pression': '', 'default_option': '', 'collation_id': 8, 'srs_id': 0, 'version_dropped': 0, 'version_added': 0, 'physical_pos':
 1, 'ct': 'int'}

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

这个走的不是False吗?
2

@ddcw
Copy link
Owner

ddcw commented Sep 25, 2024

现在不是走到 if col['isbig']:位置么, 也就是被当作了blob之类的来处理了. 要确认的是: 那几个varchar字段 col是不是含有isbig为True

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

1

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

2 这个字段 text里面含有 True

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

都检查了一下 两个字段text 类型,isbig都是True

@ddcw
Copy link
Owner

ddcw commented Sep 25, 2024

解析varchar的时候, 异常也是写的:BLOB ERROR..... 挺坑的. 你检查的是对的. 是我看错了.
那问题应该还是在record header附近. 先排除下instant的问题: 你试下低版本的v1.0-v1.5看下呢

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

1_0 1_1 1_2 1_3 1_4 1_5 都试了一下 按照顺序1.0-1.5

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

我试了另外的text 解析是成功的
1

@ddcw
Copy link
Owner

ddcw commented Sep 25, 2024

看起来低版本报错更离谱了. 也就是大概率不是instant的问题, 这就很有趣了. 能解析部分数据, 然后报错...... (也不是坏块的嘛...)
如果着急处理的话: 1. alter table import tablespace 2.ibd2sql强制解析 3. 从备份恢复.

如果不着急的话: 又不能提供原始文件, 我先想想怎么调试方便呢.....

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

大佬,急!急!急!十万火急
第一个试过了 不行,
第二个如何强制解析
第三个没有备份,尴尬的一批

@ddcw
Copy link
Owner

ddcw commented Sep 25, 2024

每页强制解析:, 速度会比较慢哈. (没有做重定向哈, 自己写就是了)

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

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

一失足成千古恨,有个操作记录表太大了,大意了直接把ibd文件删除了,导致数据库起不来了,只能通过ibd恢复,哭死

@ddcw
Copy link
Owner

ddcw commented Sep 25, 2024

ibd文件删除, 不影响数据库启动啊

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

鬼知道啊 就是把这个删除了 mysql启动就抱错

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

直接启不来。。一言难尽

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

你发的那个 是搭配shell脚本,一起执行吗?

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

是的 我已经运行了,嘎嘎猛,这种是jie xi解析成功还是失败了?
w

@ddcw
Copy link
Owner

ddcw commented Sep 25, 2024

看起来已经开始解析了, 但解析成功还是失败得看你重定向的文件里面有没得数据. 这种方法主要是针对坏块的场景的.
你把数据库启动报错的日志也提供下, 说不定有其它方法解决

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

启动报错的日志没找到,只有服务报错
1

@ddcw
Copy link
Owner

ddcw commented Sep 25, 2024

右键对应的服务, 有个属性, 里面有启动命令. 你看下启动命令里面有没有指定配置文件或者error文件, 如果没有指定配置文件的话, 应该就是读的默认配置文件. 如果有指定配置文件的话, 看下里面的error文件路径, 没得的话,就是数据目录下面

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

重定向我写错了。。尴尬
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>${current_page}.sql ;
done

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

解析成这种的,有办法吗?
1

@ddcw
Copy link
Owner

ddcw commented Sep 25, 2024

这种显然是不对的.
你把ddl脱敏后(表名,字段名字,注释之类的脱敏, 字段类型,字符集,长度,是否为空,主键等信息留着就行)发我, 我模拟下 (既然没得坏块, 那应该能复现的)

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

没有原始数据了,现在唯一的希望就是通过大佬这个工具还原数据

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

好像放在pycharm里面跑,又是另一个报错,,不过解析的数据显示的不对
1

@ssw0309
Copy link
Author

ssw0309 commented Sep 25, 2024

1

@ddcw
Copy link
Owner

ddcw commented Sep 26, 2024

看起来就是blob解析那的问题, 但应该是前面varchar读的时候就差几个字节(6), 也就是可能是null或者主键索引哪里解析的时候有问题,
你把解析出来的ddl发我, (为了安全, 建议把表名字和字段名字,注释等替换后再发出来). 看看我这能不能复现出来, 不上手操作, 我也只能猜....

@ssw0309
Copy link
Author

ssw0309 commented Sep 26, 2024

我来请示一下领导。辛苦了,大佬

@sukai-c
Copy link

sukai-c commented Oct 14, 2024

你好,请问问题有解决方案么?我好像也遇到了这个问题。就一张表数据异常,其他表用这个工具恢复了数据都正常(非常给力,给作者点赞)。

@sukai-c
Copy link

sukai-c commented Oct 14, 2024

你好,请问问题有解决方案么?我好像也遇到了这个问题。就一张表数据异常,其他表用这个工具恢复了数据都正常(非常给力,给作者点赞)。

没事了,从这个ibd文件本体里读出来的表结构不对,我对着数据一点点调整完表结构之后就好了。总之非常感谢你的工具,很棒

@ddcw
Copy link
Owner

ddcw commented Oct 15, 2024

感谢反馈!

没得样本数据,该BUG可能还会存在后续的版本中. 我后面看看能不能模拟出来

你好,请问问题有解决方案么?我好像也遇到了这个问题。就一张表数据异常,其他表用这个工具恢复了数据都正常(非常给力,给作者点赞)。

没事了,从这个ibd文件本体里读出来的表结构不对,我对着数据一点点调整完表结构之后就好了。总之非常感谢你的工具,很棒

@ddcw
Copy link
Owner

ddcw commented Oct 21, 2024

修了个BUG (varchar), 不确定是否为这个, 可以下载最新版验证下 @sukai-c @ssw0309

@ssw0309
Copy link
Author

ssw0309 commented Oct 22, 2024

Snipaste_2024-10-22_14-44-12 试了一下 还是不行

@ddcw
Copy link
Owner

ddcw commented Oct 22, 2024

从截图看还是1.6的, 我还没有打tag, 你得直接下载源码的才有: https://github.com/ddcw/ibd2sql/archive/refs/heads/main.zip @ssw0309

@ssw0309
Copy link
Author

ssw0309 commented Oct 22, 2024

大佬 出现了新的问题
Snipaste_2024-10-22_15-37-46

@ddcw
Copy link
Owner

ddcw commented Oct 22, 2024

这个报错是 当varchar存储为溢出页的时候才会走到这个逻辑, 我测试了下是能够正常解析varchar溢出页的(这部分代码也没有动过). 除非有坏块了. 你可以先检查下是否存在坏块: https://github.com/ddcw/ddcw/tree/master/python/check_innodb_file

或者加上--debug看下相关信息呢

@ssw0309
Copy link
Author

ssw0309 commented Oct 22, 2024

不存在坏快 我执行了
debug1

@ddcw
Copy link
Owner

ddcw commented Oct 22, 2024

--debug主要是看 VARCHAR: SPACE_ID:相关的信息....
self.debug(f"VARCHAR: SPACE_ID:{SPACE_ID} PAGENO:{PAGENO} BLOB_HEADER:{BLOB_HEADER} REAL_SIZE:{REAL_SIZE}")

@ssw0309
Copy link
Author

ssw0309 commented Oct 22, 2024

Snipaste_2024-10-22_17-48-23

@ddcw
Copy link
Owner

ddcw commented Oct 22, 2024

从报错来看, 很前面的字段就有问题了. 可能存在类似varchar(255)或者instant之类的BUG, 但没得相关数据文件无法确认. 也没得相关表结构可以模拟.
你也可以像sukai-c那样操作看看.

@ssw0309
Copy link
Author

ssw0309 commented Oct 22, 2024

是的 感觉像是解析某个字段失败了
然后解析的数据 也差了很多,一个值 前后都会多出一些内容

@ssw0309
Copy link
Author

ssw0309 commented Oct 23, 2024

他这个如何调整表结构的?
这个表结构 不是通过工具解析出来的吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants