You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$null=$server.Query("USE master; RESTORE DATABASE [$($db.Name)] FROM DATABASE_SNAPSHOT='$($snap.Name)'")
180
+
$restoreSuccess=$true
181
+
} catch {
182
+
# Check if this is a deadlock error (error 1205)
183
+
if ($_.Exception.InnerException.Number-eq1205) {
184
+
$retryCount++
185
+
if ($retryCount-lt$maxRetries) {
186
+
$waitSeconds= [Math]::Pow(2,$retryCount)
187
+
Write-Message-Level Verbose -Message "Deadlock detected during restore of $db on $server. Retrying in $waitSeconds seconds (attempt $retryCount of $maxRetries)"
188
+
Start-Sleep-Seconds $waitSeconds
189
+
} else {
190
+
Stop-Function-Message "Failiure attempting to restore $db on $server after $maxRetries attempts due to deadlock"-ErrorRecord $_-Continue
191
+
}
192
+
} else {
193
+
Stop-Function-Message "Failiure attempting to restore $db on $server"-ErrorRecord $_-Continue
194
+
break
195
+
}
172
196
}
197
+
}
173
198
174
-
$null=$server.Query("USE master; RESTORE DATABASE [$($db.Name)] FROM DATABASE_SNAPSHOT='$($snap.Name)'")
175
-
} catch {
176
-
Stop-Function-Message "Failiure attempting to restore $db on $server"-ErrorRecord $_-Continue
0 commit comments