Open aDisplayName opened 1 year ago
Tagging subscribers to this area: @dotnet/area-system-io See info in area-owners.md if you want to be subscribed.
Author: | aDisplayName |
---|---|
Assignees: | - |
Labels: | `area-System.IO`, `untriaged` |
Milestone: | - |
Hi @aDisplayName
First of all, there is a lot of differences between Unix and Windows when it comes to file locking:
Because of that, the behavior may be specific to OS and file system.
The problem shows up when we upgrade the OS hosting our remote data reader from Ubuntu 18.04 to Ubuntu 22.04 LTS. The problem does not show up when the data reader runs under Ubuntu 18.04 or Ubuntu 20.04
The problem applies to .NET 6.0, 7.0 and 8.0 RC1
Most likely Ubuntu has changed something related to file locking (or we are no longer able to recognize the file system). We will most likely need to recognize it similarly to what we did in https://github.com/dotnet/runtime/pull/55256 for NFS/CIFS/SMB.
To unblock you, you can disable file locking. This can be done by using System.IO.DisableFileLocking app context switch or DOTNET_SYSTEM_IO_DISABLEFILELOCKING environment variable.
It makes .NET stop respecting file locks, so for example if you open a file with exclusive access you can no longer assume nobody else is reading from it/writing to it. It can be a major problem if you are using files for synchronization.
To unblock you, you can disable file locking. This can be done by using System.IO.DisableFileLocking app context switch or DOTNET_SYSTEM_IO_DISABLEFILELOCKING environment variable.
It makes .NET stop respecting file locks, so for example if you open a file with exclusive access you can no longer assume nobody else is reading from it/writing to it. It can be a major problem if you are using files for synchronization.
@adamsitnik Thank you for the insight. We've tested the workaround by using the environment variable, and the conflicts seemed disappeared on the data generation side.
Description
We are facing a problem, that a on-going local file writing operation will be blocked, using C++ standard library as soon as the same file is opened in read-only mode from the remote network share by a remote data reader within Ubuntu 22, even the 2nd party opened the file After the original file has already been opened for writing.
The file generation must use a block size of 8192 bytes or more for the problem to show up.
The problem shows up when we upgrade the OS hosting our remote data reader from Ubuntu 18.04 to Ubuntu 22.04 LTS. The problem does not show up when the data reader runs under Ubuntu 18.04 or Ubuntu 20.04
The problem applies to .NET 6.0, 7.0 and 8.0 RC1
Reproduction Steps
Setup
We are using a readonly network share to share file content across two OS:
According to mount.cifs(8) man pages, we also tried the combination of different options -o:
Step to reproduce
App 1@Windows 10: Microsoft VC++ 14.3: A C++ program is created to continuously writing data to the a file
shared_data\test.dat
:To reproduce the problem, the block size must be at least of 8192 bytes or more:
App 2: After the App1 started on the Windows side, running the following .NET 6.0/7.0/8.0 RC1 C# program under Ubuntu 22.04 LTS towards the same file over the mounted share folder
~/fileserver/test.dat
:Strangely, the behavior we've found out, is that as soon as we started App 2 over the Ubuntu, the writing action ('LABEL A' in App 1) will fail:
Here is the explanation from Microsoft about the error code 13: https://learn.microsoft.com/en-us/cpp/c-runtime-library/errno-constants?view=msvc-170#remarks
Expected behavior
No file access conflicts from either data generator on Windows side, or the data reader on the Ubuntu side. Even if the data reader has trouble to access data for read, the file generation on the Windows side should not be affected.
Actual behavior
File generation on the Windows side was denied access when the same file is being accessed by .NET application in readonly mode as stated in the sample code.
Regression?
No response
Known Workarounds
We have tried the following non-dotnet based data reader, and they do not causing problem on the data generation side:
A simple python code in python 3.10
Configuration
No response
Other information
No response