Bug #116933 Function recv_single_rec doesn't handle corrupt_log correctly
Submitted: 11 Dec 2024 1:47 Modified: 11 Dec 2024 5:31
Reporter: mengchu shi (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:8.0,8.4 OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution, recovery crash, redo apply

[11 Dec 2024 1:47] mengchu shi
Description:
Function recv_single_rec doesn't handle corrupt_log while function recv_multi_rec return true immediatly.
If this parse round happens to reach the memory bottleneck to call function recv_apply_hashed_log_recs, This bug will cause redo logs after the corrupt_log be applied and maybe corrupt datas.
I think it's not by design, right?

How to repeat:
Just see the codes please:
```c++
static bool recv_single_rec(byte *ptr, byte *end_ptr) {
  ...
  if (recv_sys->found_corrupt_log) {
    recv_report_corrupt_log(ptr, type, space_id, page_no);

#ifdef UNIV_HOTBACKUP
    return true;
#endif /* UNIV_HOTBACKUP */

  } else if (len == 0 || recv_sys->found_corrupt_fs) {
    return true;
  }
  ...
}
```
```c++
static bool recv_multi_rec(byte *ptr, byte *end_ptr) {
  ...
    if (recv_sys->found_corrupt_log) {
      recv_report_corrupt_log(ptr, type, space_id, page_no);

      return true;

    } else if (len == 0) {
      return true;

    } else if ((*ptr & MLOG_SINGLE_REC_FLAG)) {
      recv_sys->found_corrupt_log = true;

      recv_report_corrupt_log(ptr, type, space_id, page_no);

      return true;

    } else if (recv_sys->found_corrupt_fs) {
      return true;
    }
...
}
```

Suggested fix:
Function recv_single_rec should handle corrupt_log the same as function recv_multi_rec. So remove #ifdef UNIV_HOTBACKUP.
[11 Dec 2024 1:48] mengchu shi
recv_single_rec_should_handle_corrupt_log.patch

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: recv_single_rec_should_handle_corrupt_log.patch (application/octet-stream, text), 526 bytes.

[11 Dec 2024 5:31] MySQL Verification Team
Hello mengchu shi,

Thank you for the report and contribution.

regards,
Umesh