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

Restore-SqlDatabase times out with "The wait operation timed out" #60

Open
tn-5 opened this issue Sep 8, 2023 · 5 comments
Open

Restore-SqlDatabase times out with "The wait operation timed out" #60

tn-5 opened this issue Sep 8, 2023 · 5 comments

Comments

@tn-5
Copy link

tn-5 commented Sep 8, 2023

When restoring a large database using Restore-SqlDatabase the command times out after 600 seconds. This is regardless of the ConnectionTimeout parameter setting. Tried setting it to 0 and setting it to a large number, it always times out. When using Invoke-Sqlcmd to restore the same it works when setting QueryTimeout to 0

@StanDaMan0505
Copy link

Can confirm. The same happens to us.
SqlServer Modul 22.2.0 times out after 10 minutes
SqlServer Modul 21.1.18256 works fine same server and same database
Might be an issue together with -TrustServerCertificate?

@recepdirek
Copy link

I have the same issue on my powershell restore script.
Restore-SqlDatabase -ServerInstance $TargetSqlServerInstance -Database $TargetDb -BackupFile $RestoreFile -RelocateFile @($RelocateData,$RelocateLog) -ReplaceDatabase -ConnectionTimeout 0 -TrustServerCertificate

updated database connection timeout to 0 and used that -ConnectionTimeout on the command but it didn't work.
Got the error below:

powershell.exe : Restore-SqlDatabase : The wait operation timed out
At line:1 char:1

  • powershell.exe -File C:\db_refresh\db_refresh.ps1
  •   + CategoryInfo          : NotSpecified: (Restore-SqlData...ation timed out:String) [], RemoteException
      + FullyQualifiedErrorId : NativeCommandError
    
    

At C:\db_refresh\db_refresh.ps1:45 char:1

  • Restore-SqlDatabase -ServerInstance $TargetSqlServerInstance -Databas ...
  •   + CategoryInfo          : InvalidOperation: (:) [Restore-SqlDatabase], Win32Exception
      + FullyQualifiedErrorId : ExecutionFailed,Microsoft.SqlServer.Management.PowerShell.RestoreSqlDatabaseCommand``
    

@tn-5
Copy link
Author

tn-5 commented Apr 12, 2024

Looks like separate ConnectionTimeout (to establish the connection) and QueryTimeout (to execute the actual SQL) paramters are needed for all commands, especially for those that are expected to be long running (such as restores)

@recepdirek
Copy link

I was using the Restore-SqlDatabase command, so it wasn't possible to set those separately. But I will try to use Invoke-Sqlcmd instead Restore-SqlDatabase.

@tn-5
Copy link
Author

tn-5 commented Apr 12, 2024

Yes, Invoke-Sqlcmd works since it supports the QueryTimeout parameter. Then you however lose the nice features of Restore-SqlDatabase like the progress indicator etc.

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