twindb / undrop-for-innodb

TwinDB data recovery toolkit for MySQL/InnoDB
https://twindb.com
GNU General Public License v2.0
384 stars 148 forks source link

deleted_records_only #6

Open cothee opened 6 years ago

cothee commented 6 years ago

when looking for deleted records only, why we consider all pages are not valid?(in c_parser.c, line 512)

akuzminsky commented 6 years ago

It's by design. "Valid" maybe is not the best name, but it actually means that you can travel from the infimum to supremum record following "next record pointers". InnoDB will skip any deleted records because InnoDB updates "next record pointer" to remove a deleted record from a chain of records. So, to find any deleted records c_parser doesn't check if a page is valid or not, it considers the page invalid and scans the page byte by byte.

cothee commented 6 years ago

In this way, when finding deleted records, we should scan all of the records that after supremum in physical position. so the start offset should be no less than (supremum + 8, ie. 112 + 8). But in the c_parser, the start offset is 100 + REC_N_NEW_EXTRA_BYTES(which is 5 in compact format). I just can not figure why 105, and I think maybe this is a bug when finding deleted records. BTW, why don't you scan deleted records start by PAGE_FREE pointer? That will just find the deleted records.

akuzminsky commented 6 years ago

I doesn't really matter where to start, at 105 or 120. The supremum record won't match anyway. The tool used to scan from the byte zero, but there were some crashes, so I moved the starting point a bit. So, we can call it historical reasons.