From a99b97cc89093397f65f6cbc71eb5229a924975b Mon Sep 17 00:00:00 2001 From: aholstrup1 Date: Tue, 30 Jun 2026 15:32:10 +0200 Subject: [PATCH] Restart container before restoring demo data snapshot to free DB connections The demo-data retry restore failed with 'Exclusive access could not be obtained because the database is in use' because Stop-NAVServerInstance returns before the deadlocked NAV session's SQL connection drains. Restart the container first so the restore can obtain exclusive access on 'default'. --- build/scripts/ImportTestDataInBcContainer.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build/scripts/ImportTestDataInBcContainer.ps1 b/build/scripts/ImportTestDataInBcContainer.ps1 index 2f99687dfe..f3f4f5fd75 100644 --- a/build/scripts/ImportTestDataInBcContainer.ps1 +++ b/build/scripts/ImportTestDataInBcContainer.ps1 @@ -187,6 +187,11 @@ function Restore-TenantDatabaseForDemoDataRetry { [string]$BackupFile ) + # Restart the container to drop lingering connections to 'default' so the restore can obtain exclusive access. + Write-Host "Restarting container to release lingering database connections before restoring snapshot..." + Restart-BcContainer -containerName $ContainerName + Wait-ForTenantReady -ContainerName $ContainerName + Write-Host "Restoring tenant database from snapshot before retrying demo data generation..." Invoke-ScriptInBcContainer -containerName $ContainerName -scriptblock { Stop-NAVServerInstance -ServerInstance $ServerInstance