Bug #90264 Some file operations in mf_iocache2.c are not instrumented
Submitted: 30 Mar 15:54 Modified: 3 Sep 22:09
Reporter: Yura Sorokin (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Performance Schema Severity:S3 (Non-critical)
Version:5.5.59, 5.6.39, 5.7.21 OS:Any
Assigned to: Marc Alff CPU Architecture:Any
Tags: Contribution

[30 Mar 15:54] Yura Sorokin
Description:
my_b_append_tell(), my_b_fill() and my_b_filelength() functions from 'mf_iocache2.c' use non-instrumented file tell/seek/read functions (my_tell(), my_seek() and my_read()) instead of their instrumented version (mysql_file_tell(), mysql_file_seek() and mysql_file_read()).

This causes inaccurate statistics in PERFORMANCE_SCHEMA.

How to repeat:
Run
./mysql-test/mtr --debug-server perfschema.relaylog

"============ Performance schema on master ============"
 select
 substring(file_name, locate("master-", file_name)) as FILE_NAME,
 EVENT_NAME,
 if (count_read > 0, "MANY", "NONE") as COUNT_READ,
 if (count_write > 0,"MANY", "NONE") as COUNT_WRITE,
 if (sum_number_of_bytes_read > 0, "MANY", "NONE") as SUM_NUMBER_OF_BYTES_READ,
 if (sum_number_of_bytes_write > 0, "MANY", "NONE") as SUM_NUMBER_OF_BYTES_WRITE
 from performance_schema.file_summary_by_instance
 where file_name like "%master-%" order by file_name;

This query (and similar) should return 'MANY' for 'COUNT_READ' and 'SUM_NUMBER_OF_BYTES_READ' instead of 'NONE'

Suggested fix:
Change my_tell() / my_seek() / my_read() to mysql_file_tell() / mysql_file_seek() / mysql_file_read() in 'mf_iocache2.c'.

See the attached patches.
[30 Mar 17:20] Yura Sorokin
Patch for 5.5

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

Contribution: bug90264-5_5.diff (application/octet-stream, text), 5.04 KiB.

[30 Mar 17:20] Yura Sorokin
Patch for 5.6

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

Contribution: bug90264-5_6.diff (application/octet-stream, text), 5.22 KiB.

[30 Mar 17:21] Yura Sorokin
Patch for 5.7

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

Contribution: bug90264-5_7.diff (application/octet-stream, text), 7.42 KiB.

[31 Mar 4:58] Umesh Shastry
Hello Yura Sorokin,

Thank you for the report and contribution.

Thanks,
Umesh
[20 Aug 14:07] Marc Alff
Hi Yura Sorokin,

Thanks for :
- the bug report,
- the contribution with the fix.

Regards,
-- Marc Alff
[3 Sep 22:09] Paul Dubois
Posted by developer:
 
Fixed in 5.5.62, 5.6.42, 5.7.24, 8.0.13.

Previously, file I/O performed in the I/O cache in the mysys library
was not instrumented, affecting in particular file I/O statistics
reported by the Performance Schema about the binary log index file.
Now, this I/O is instrumented and Performance Schema statistics are
accurate. Thanks to Yura Sorokin for the contribution.