Bug #102010 No need to parse log twice in recv_multi_rec
Submitted: 16 Dec 2020 11:25 Modified: 27 Jan 2021 18:30
Reporter: zhai weixiang (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S5 (Performance)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any

[16 Dec 2020 11:25] zhai weixiang
Description:
In function recv_multi_rec, it firstly parse the whole mtr to confirm that it's complete and then parse second time for adding it to hash. Actually the second parse is not necessary. Because parsing redo is time-costing, we can store the parsed content in first loop. For example, use a structrue like this to store the content and iterate it for adding them to hash. 

struct MultiContent {
  mlog_id_t type;
  ulint len;
  byte *body;
  byte *rec_end;
  space_id_t space_id;
  page_no_t page_no;
}

#define MAX_MULTI_CONTENT_ARRAY_SIZE 8192

struct recv_sys_t {
...
MultiContent multi_recs[MAX_MULTI_CONTENT_ARRAY_SIZE];
...
}

How to repeat:
read the code

Suggested fix:
desc above
[16 Dec 2020 12:39] zhai weixiang
a simple patch to describe the optimization

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

Contribution: parse.diff (application/octet-stream, text), 3.03 KiB.

[16 Dec 2020 14:35] MySQL Verification Team
Hi Mr. weixiang,

Thank you for your performance improvement report.

I have analysed carefully our current code and your patch and I have to agree that it brings some improvement.

Verified as reported.
[27 Jan 2021 18:30] Daniel Price
Posted by developer:
 
Fixed as of the upcoming 8.0.24 release, and here's the proposed changelog entry from the documentation team:

During recovery, log records for multiple record group mini transactions
were parsed twice. The log record from the first parsing operation is now
saved to avoid the second pass, which improves recovery performance.

Thanks to Zhai Weixiang for the contribution.
[28 Jan 2021 12:50] MySQL Verification Team
Thank you, Daniel .....