Bug #89822 InnoDB retries open on EINTR error only if innodb_use_native_aio is enabled
Submitted: 27 Feb 7:46 Modified: 27 Feb 10:42
Reporter: Laurynas Biveinis (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:5.7,8.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution

[27 Feb 7:46] Laurynas Biveinis
Description:
EINTR is a possible error on a failed open call. How it will be handled in InnoDB depends on innodb_use_native_aio value, which should not have any connection to open returning EINTR.

How to repeat:
Code analysis. os_file_create_simple_func open call returning EINTR will call os_file_handle_error, which will call os_file_handle_error_cond_exit. If innodb_use_native_aio is ON, it will return OS_FILE_AIO_INTERRUPTED (it is also not correct name as EINTR may be returned by non-AIO I/O, such as open here), and if OFF, it will return OS_FILE_ERROR_MAX + EINTR.

os_file_handle_error will return true for os_file_create_simple_func retry variable, and false otherwise.

os_file_create_simple_func(
...
	do {
		file.m_file = ::open(name, create_flag, os_innodb_umask);

		if (file.m_file == -1) {
			*success = false;

			retry = os_file_handle_error(
				name,
				create_mode == OS_FILE_OPEN
				? "open" : "create");
		} else {
			*success = true;
			retry = false;
		}

	} while (retry);

...

os_file_handle_error(
...
	/* Exit in case of unknown error */
	return(os_file_handle_error_cond_exit(name, operation, true, false));
	switch (err) {
...
	case OS_FILE_AIO_INTERRUPTED:

		return(true);
...
	default:
                // diagnose, abort, etc
}

os_file_handle_error_cond_exit(
...
	err = os_file_get_last_error_low(false, on_error_silent);

os_file_get_last_error_low(
...
	int	err = errno;
...
	switch (err) {
...
	case EINTR:
		if (srv_use_native_aio) {
			return(OS_FILE_AIO_INTERRUPTED);
		}
		break;
...
	return(OS_FILE_ERROR_MAX + err);

Suggested fix:
While a mount where open may return EINTR is probably not the best system for running InnoDB, this is still inconsistency and EINTR should be retried regardless of native AIO setting.
[27 Feb 8:37] Laurynas Biveinis
Bug 89822 fix for 8.0.4

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

Contribution: bug89822-8.0.4.patch (application/octet-stream, text), 841 bytes.

[27 Feb 10:42] Umesh Shastry
Hello Laurynas,

Thank you for the report and contribution.

Thanks,
Umesh
[13 Jun 12:51] Laurynas Biveinis
Bug 89822 fix for 8.0.11

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

Contribution: bug89822-8.0.11.patch (application/octet-stream, text), 922 bytes.

[14 Jun 5:03] Umesh Shastry
Thank you for the contributions!

Regards,
Umesh