Bug #108860 InnoDB clone I/O errors from worker threads report incorrect errno
Submitted: 24 Oct 2022 11:36 Modified: 25 Oct 2022 5:54
Reporter: Laurynas Biveinis (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:8.0.31 OS:Any
Assigned to: CPU Architecture:Any
Tags: Clone

[24 Oct 2022 11:36] Laurynas Biveinis
Description:
Suppose an I/O error happens during InnoDB clone in one of the worker threads, for example ER_ERROR_ON_READ. This thread will call Clone_Task_Manager::set_error, which will save the error by setting the m_saved_error and m_err_file_name fields.

At some point later the clone connection thread will call Clone_Task_Manager::handler_error_other_task, which, for I/O errors, will call my_error as follows:
 
    my_error(m_saved_error, MYF(0), m_err_file_name.c_str(), errno,
               my_strerror(errbuf, sizeof(errbuf), errno));
 
Here m_saved_error and m_err_file_name will be the ones set by the previous set_error call, but note that errno is also reported. This errno value, being thread-local, will have no relation to any errno of the worker thread at the time of error occurrence, and will be misleading as a part of this diagnostics.

How to repeat:
Code analysis.

Suggested fix:
Introduce m_errno field, set it in set_error, report it in handle_error_other_task.
[25 Oct 2022 5:54] MySQL Verification Team
Hello Laurynas,

Thank you for the report and feedback!

regards,
Umesh