Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows file share: why sometimes newly created files aren't visible for some period of time?
    primarykey
    data
    text
    <p>We were faced with very strange issue that made us crazy. Sometimes newly created files on our File Share PC were "absent" for some period of time. To reproduce a problem you should have at least two computers, call them <code>alpha</code> and <code>beta</code>. Create file share on <code>beta</code> PC (<code>\\beta\share\bug</code>) and run this PowerShell script from <code>alpha</code> PC:</p> <pre><code>param( $sharePath="\\beta\share\bug" ) $sharePC = ($sharePath -split '\\')[2] $session = New-PSSession -ComputerName $sharePC $counter = 0 while ($true) { $fileName = $sharePath + "\$counter.txt" Invoke-Command -Session $session -ScriptBlock { param( $fileName ) "" &gt; $fileName } -ArgumentList $fileName if (Test-Path $fileName) { Write-Host "File $fileName exists" -fore Green } else { Write-Host "!!! File $fileName does NOT exist!" -fore Red } $counter = $counter + 1 Start-Sleep 2 } </code></pre> <p>After starting this script you should be able to see these messages:</p> <pre><code>File \\beta\share\bug\1.txt exists File \\beta\share\bug\2.txt exists ... </code></pre> <p><strong>And now</strong>: Open <code>cmd.exe</code> and run this command:</p> <p><code>if exist \\beta\share\bug\foo.txt echo 1</code></p> <p>After this during approx 10 seconds you'll see following messages:</p> <pre><code>!!! File \\beta\share\bug\3.txt does NOT exist! !!! File \\beta\share\bug\4.txt does NOT exist! </code></pre> <p>We've discovered that bug is caused by enumerating shared directory where new files are being created. In <code>Python</code> call <code>os.listdir('//beta/share/bug')</code> to reproduce a bug. In <code>C#</code>: <code>Directory.GetDirectories(@"\\beta\share\bug")</code>. You can even simply navigate to share directory by shell and call <code>ls</code> or <code>dir</code>.</p> <p>Bug were found on <code>Windows Server 2008 R2</code></p> <p>Note, that you cannot watch directory content on <code>alpha</code> PC in Windows Explorer in real time, because if you open this directory in Explorer bug would not occur! So ensure to close all such windows before attempts to reproduce a bug. After each script restart you should manually remove all already created files from share (because script is rather stupid and always starts from 0.txt).</p> <p>We currently have 2 workarounds for this issue:</p> <ol> <li>If client sees this situation, it creates some temporary file in problematic directory - after this files magically appear.</li> <li>Disable SMB 2.0: <a href="http://www.petri.co.il/how-to-disable-smb-2-on-windows-vista-or-server-2008.htm">http://www.petri.co.il/how-to-disable-smb-2-on-windows-vista-or-server-2008.htm</a></li> </ol> <p>Does anybody have ever discovered similar problem and can explain why it occurs and how "correctly fix" it?</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload