-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
os: File.Close throws interrupted system call (EINTR) error #44964
Comments
Does calling |
This is an interesting case. POSIX does not define what happens if Presumably we see You report that you are sometimes seeing corrupted files on disk, so there really was an error. The close operation really was interrupted by a signal, the system call was not restarted, and So I don't see any solution. I'm open to suggestions. I would imagine that you could create the same problem with a pure C program, and would have the same difficulty in how to address it. It seems like a bug in how the mount of the Azure file system handles signals, one with no obvious workaround. |
@ianlancetaylor I don't know much of C sorry about that. I'll see if I can build a C program to test it against. |
@ianlancetaylor I tried the sample c code it did not yield EINTR error by terminal resizing so I had to write a go script to sent SIGWINCH for the running (C program) PID. I ran the executable(C exec) multiple times. And the only time it failed it errored with "Input/output error" EIO. I'm not very confident with my C code so I can't probably speak much as to why it did not error with If it helps the go program that was sending SIGWINCH to running C program Pid look somewhat like this
|
A user-code workaround may be to call f.Sync() before f.Close(). If either of those fails, you should abort. |
@networkimprov That could have a possible solution but because of the EINTR error on Just an update I'm also speaking with Azure tech support about this as @ianlancetaylor suggested it could be a bug on the Azure file system on how it handles signals. |
Have you tried writing the file at a temporary path, then f.Sync() and rename it? On failure, remove the temporary path if it exists, then start over if the renamed path doesn't exist. See also: https://danluu.com/file-consistency/ |
@meetme2meat To get equivalent C code the C program needs to use the |
At this point I don't see anything that we could change in Go to fix this problem. So I am going to close this issue. I am definitely open to suggestions if anybody has any ideas, but for now I think this can only be regarded as a bug in the file system implementation, or possibly the kernel. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
The binary was build using the go1.16 version (installed on my mac) and our production binaries are build using go 1.15.x.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I build the binary from the following script https://play.golang.org/p/U-SEH0ACtZ2
Started a docker with ubuntu
Mounted the Azure File share at
/data/cdrs
as described hereNote: This is exactly how our production is setup(where we are seeing similar a problem), except for building the binary which we do use the multi-stage docker image
Copied the binary onto the docker container
What did you expect to see?
No error while writing the file to disk
What did you see instead?
The problem is easier to trigger when the terminal window is continously resized (this triggers SIGWINCH signals).
Because of EINTR at times we are seeing corrupted files(incomplete write) getting written to disk.
The text was updated successfully, but these errors were encountered: