1

first time posting here! i dont have reputation points for inline images and links yet, sorry.

Short version:

I am investigating an issue reported by our users. they have batch scripts that rapidly copy/merge/rename/zip/delete files on a network share, and sometimes the batchfile crashes because it cannot find/access one of the files.

When opening the share in windows explorer and hitting F5 rapidly this drastically increases the error rate. Leaving the folder alone by closing explorer completely, would remove the problem nearly entirely.

I have narrowed it down to (probably) being an issue with windows explorer or smb2.x on windows7 and 2008r2. Win8, Win10 and 2012R2 do not show this issue. I want to verify with the community if this is an error in my testing methods, or there is indeed a bug in the OS.

Long version, steps to reproduce, tested workarounds:

To test the problem a batch file was created

  • Create a file with a random number inside
  • Rename the file 4 times (e.g. file.txt -> file.bak -> file.old -> file.txt)
  • Read the content of the file and compare the numbers

This runs in an endless loop, and in a system without cpu/memory errors, it should never fail. But it does – sometimes it simply can’t find the file it is supposed to rename or read (e.g. it fails with “cannot find file.old”)

here is an example screenshot:

batchfile error
click to enlarge

To make sure this is not a problem in the batchfile itself, I coded a small c# program which essentially does the same. I can reproduce the problem 1:1 with this program.

During testing I noticed when I have the target folder open in windows explorer, the problem happened more often, than when I did not have the folder open. i suspected a relation to "auto-refresh". by “forcing” this condition (F5 button) i could reproduce the issue now each time very quickly.

So I made the following test: serverfault.com/questions/642254/files-not-appearing-caching-or

Disable explorer auto-refresh settings on win7 client

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer]
    "NoRemoteRecursiveEvents"=dword:00000001  
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer]
    "NoRemoteChangeNotify"=dword:00000001  

this solved the issue when not touching the keyboard, the program runs for a long time without issues. but as soon as i manually hit and keep pressing F5 to rapidly refresh explorer, the problem appears again:

manual refresh
click to enlarge

My conclusion at this point: explorers “refresh” function causes an issue in the “network” transmission, or a file lock, sharing violation, etc…?

Further investigation: I wanted to find out on which systems this happens, so I ran a lot of tests on different OSes (always using the F5 refresh trick). I could reproduce this issue in win7 and 2008r2 only, win8,10 and 2012r2 went error-free. I ruled out company security settings by running the tests on non-domain joined VMs, and on private computers at home, the problem is existing there also.

the only thing left to test was the SMB version, so i disabled SMB2.x on win7 (http s://support.microsoft.com/de-de/kb/2696547)

    sc.exe config lanmanworkstation depend= bowser/mrxsmb10/nsi 
    sc.exe config mrxsmb20 start= disabled

result: the problem was "solved" (more of a workaround) by switching to SMB1.5 on windows 7.

Conclusion:

rapidly creating/renaming files on network shares while refreshing the explorer folder causes issues on win7 and 2008r2, when using SMB2.x. switching to SMB 1.5 solves issue. newer OS are not affected, regardless of SMB version.

My questions are:

  • Do I test this correctly, can someone reproduce this? batchfile and c# source are in the pastebin links.
  • Is windows explorer or the smb stack on win7/2008r2 buggy? should I open a MS support ticket?
  • Are there any additional settings to fine-tune SMB/lanman service/etc which could help in this case?

batchfile -> pastebin.com/Dc2QHB8y

c# test program -> pastebin.com/Xx11MFdr

systems test list -> pastebin.com/p24Jz0Aw

magicandre1981
  • 1,110
  • 2
  • 10
  • 20
Robert R
  • 31
  • 8

0 Answers0