-
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.Sync() returns ENOTSUP on network mounts that support fsync #64215
Comments
Thanks. It seems plausible to default to fsync if we get ENOTSUP in those platforms. /cc @golang/darwin |
Change https://go.dev/cl/543535 mentions this issue: |
I found this post mentioning the issue: https://macosx.com/threads/smb-samba-for-time-machine-backup.324958/ Although I don't have a SMB server to test this against, falling back to syscall.Fsync on ENOTSUP seems to be a fairly safe fix for the issue. |
For testing purposes, spinning up Samba configured with:
will show appropriate logging to verify that fsyncs are occurring as expected |
This is a bug in internal/poll.Fsync (os.File.Sync() as well) on darwin that only affect SMB mounts. There is no way around it AFAIK and it has been around circa 2018, after CL 130676 was merged. Given that we entered a freeze, I want to check if the proposed fix at CL 543535 is worth submitting for 1.22 and if this bug deserves backports for 1.20 and 1.21. cc @golang/release |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
strict sync = yes
, the default since Samba 4.7.0)file.Sync()
What did you expect to see?
No error. The fsync instruction is passed down to the network share, which takes action (or not, depending on its configuration)
What did you see instead?
Error:
ENOTSUP
It appears that a change was implemented in go1.12 for #26650 which switched File.Sync() to call
fcntl(fd, F_FULLFSYNC)
rather thanfsync(fd)
. This was due to fsync not being implemented as expected on darwin.On local volumes, this change appears to work correctly. However,
F_FULLFSYNC
appears to be unsupported on SMB volumes--and likely elsewhere too.This means that the change as a result of #26650 leads to
ENOTSUP
being returned where a Sync would have succeeded before.(I've verified via samba logging that calling
unix.Fsync()
on the fd results in the correct fsync instruction being sent to the server, so darwin's wonky fsync() behaviour seems to only apply to local volumes)I'd bet that most Go developers are not testing file operations in SMB mounts, so are shipping software that would have worked in 1.11, but in 1.12+ will fail.
I've had to resort to a workaround:
The text was updated successfully, but these errors were encountered: