Backup fails with error 59 on a network disk: raise SessTimeout
Fix SQL Server backup errors 3202 and 3013 (operating system error 59 on FlushFileBuffers) by raising the LanmanWorkstation SessTimeout registry value.
A backup written to a network-mounted disk can fail with operating system error 59 during FlushFileBuffers. SQL Server then reports the following errors:
Msg 3202, Level 16, State 1, Line 1
failed: 59(An unexpected network error occurred.)
Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.
In the reported case, raising the SessTimeout value of the LanmanWorkstation service solved the problem without a server or service restart.
Registry change
Set the following value on the server that writes the backup:
| Key | Value name | Type | Data |
|---|---|---|---|
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters |
SessTimeout |
DWORD | 3600 (seconds) |
To set it with the Registry Editor, right-click Parameters, choose New, then DWORD (32-bit) Value, name it SessTimeout and set its value to 3600. Export the key before editing it.
Apply the change remotely
Enable PowerShell remoting on the target server first. It is disabled by default.
PS C:\> Enable-PSRemoting -Force
WinRM has been updated to receive requests.
WinRM service type changed successfully.
WinRM service started.
WinRM has been updated for remote management.
WinRM firewall exception enabled
Then add the value with Invoke-Command:
$serverName = "sqlserver01"
Invoke-Command -ComputerName $serverName -ScriptBlock { reg add "HKLM\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters" /v SessTimeout /t REG_DWORD /d 3600 /f }
As an alternative, use PsExec from Sysinternals. Copy the PsExec files into C:\Windows, then run:
psexec \\sqlserver01 reg add "HKLM\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters" /v SessTimeout /t REG_DWORD /d 3600 /f
References
Notes
- The reported case describes a mounted NFS disk, while the value is read by LanmanWorkstation, the Windows workstation service. Check the type of share before applying the change.
- The fix was reported as working without a restart. Verify it on your own server.