Bug #71183 os_file_fsync() should handle fsync() returning EINTR
Submitted: 19 Dec 2013 12:46 Modified: 27 Feb 2018 7:47
Reporter: Laurynas Biveinis (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:all OS:Any
Assigned to: CPU Architecture:Any
Tags: EINTR, fsync
Triage: Needs Triage: D5 (Feature request)

[19 Dec 2013 12:46] Laurynas Biveinis
Description:
fsync() is documented by POSIX to have EINTR as one of the valid return values [1]. Thus, os_file_fsync() should handle it and retry instead of failing.  Note that the same function in mysys (my_sync()) does this.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html

This was discovered while fixing bug 60788 in Percona Server.

How to repeat:
Code analysis

Suggested fix:
The function already has a retry loop, add a case for ret == -1 && errno == EINTR.
[19 Dec 2013 18:54] Sveta Smirnova
Thank you for the report.

Verified as described, although comments explicitly say: "Wrapper to fsync(2) that retries the call on *some* errors." SO nobody promised to retry on all errors.

If you have usage scenarios why such a retry can help please provide them.
[4 Nov 2014 15:19] Laurynas Biveinis
Bug 71183 fix 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: bug71183.patch (application/octet-stream, text), 795 bytes.

[19 Feb 2018 3:41] Laurynas Biveinis
This has been fixed by WL#7696 (98909cefbc37e54efc6452c7e95bccbf64ac9213) and can be closed.

The current 5.7 does not handle EINTR for open call if !innodb_use_native_aio, this will be reported separately.
[27 Feb 2018 7:47] Laurynas Biveinis
open EINTR handling reported as bug 89822