Skip to content
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

NFS race condition with locked files (Windows 10) #108

Open
dev-rke opened this issue Apr 28, 2017 · 6 comments
Open

NFS race condition with locked files (Windows 10) #108

dev-rke opened this issue Apr 28, 2017 · 6 comments

Comments

@dev-rke
Copy link

dev-rke commented Apr 28, 2017

Hi,

we found out, that re-indexing files using PHPStorm might let the NFS service freeze for a specific file. This seems to be like a race condition, because sometimes it works for multiple hours, sometimes it dies suddenly after vagrant up.

We have a cache directory in our application for generated files and when PHP is writing to these files, it seems that PHPStorm is indexing this file, so it is reading from this file.
Therefore i assume (!) that PHPStorm sets an exclusive lock to this file, and this causes the NFS service to fail. Furthermore the service isn't able to write/read from this file again.

When we set the folder exclusion in PHPStorm for the cache folder (Right click the file/folder, Mark directory as excluded), the issue seems to be gone, but we need to do further testing to ensure this.

Might it be, that the NFS service generally dies, when an exclusive lock to a file exists?

Update:
It is not totally fixed, but we can work now for several hours. We also try now to disable Windows firewall and exclude Windows Defender and Microsoft Security Essentials from watching this cache folder.
Has anybody else issues with Windows 10?
Maybe this also refers to #104, whereas our cache folder is written by the PHP function "file_put_contents".

Environment:
Windows 10
PHPStorm 2017.1.3
vagrant 1.9.3

@dev-rke dev-rke changed the title NFS race condition with PHPStorm file indexer NFS race condition with locked files Apr 28, 2017
@dev-rke dev-rke changed the title NFS race condition with locked files NFS race condition with locked files (Windows 10) Apr 28, 2017
@dev-rke
Copy link
Author

dev-rke commented May 8, 2017

Ok, there seems to be definitively an issue with winnfsd.
When i lock a file of the cache folder manually in the host (e.g. using Excel to set an exclusive lock), try to write to this file from within the VM (which will result in no change), then unlock the file in the host by closing Excel, i still cannot write to the file again.

@marcharding
Copy link
Member

Hey, i'using phpstorm too and do not experience this problem. I'll try to look into it.

@dev-rke
Copy link
Author

dev-rke commented Jun 1, 2017

Do you have files which are changed from inside vagrant?
I experience this especially when using file_put_contents and the file is larger than 32kB.
The issue happens not all the time, but from time to time.
Sometimes the issue occurs after 2 minutes, sometimes you can work up to 4 hours without having the issue.
I can successfully reproduce the issue when locking the file in the host operating system.

My temporary workaround: when the issue occurs, i execute a simple php script which just deletes these temporary files. Then the nfs service seems to update the local cached filesystem structure and the file can be created again using file_put_contents.

Just for backreference, i also added a comment in the winnfs project: winnfsd/winnfsd#32

My assumption is, that in the ProcedureWrite (https://github.com/winnfsd/winnfsd/blob/master/src/NFS3Prog.cpp#L712) the cached file system information should be updated. Otherwise write requests only process cached information and the method throws an access error. Unfortunately this would reduce data throughput a little bit, but it would be more reliable as the filesystem information is not provided from cached information.

@dev-rke
Copy link
Author

dev-rke commented Aug 22, 2017

Source of the main issue is found:
Windows Defender. It seems Windows Defender seems to lock these files.
You definitivly have to restart your machine when you exclude these folders, otherwise Windows Defender won't behave differently. Using other Antiviruses did not produce such issues.

But we still have sometimes (approximatly 2 times a day) in combination with PHPstorm.
Therefore i assume there is still a bug in this application.

It's now handleable for us, but it would be great to also fix this bug, therefore i keep this ticket open.

@jantomicky
Copy link

@dev-rke Thanks for mentioning the Windows Defender. Helped me solve a problem with gulp outputting a 0 byte file and the NFS server freezing for that specific file until I reloaded Vagrant & the NFS server.

Might be related to #104 and composer/composer#5707

@dev-rke
Copy link
Author

dev-rke commented Aug 19, 2018

Hi,

i am glad, that you were able to reproduce the issue. :-D
#104 is based on this issue.
They need to check if a file is locked on the host, before writing into it. Unfortunately it is impossible to send the information back to the applications inside vagrant, as the NFS protocol does not support file locking.
Therefore in my opinion they should set up a FAQ and recommend to exclude project folders from antivirus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants