Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bo Jacobsen 606 posts 2404 karma points
    May 02, 2022 @ 07:18
    Bo Jacobsen
    0

    Reconnection to database after lost connection do not work until a restart of the appool is made

    Hi all.

    We occasionally lose connection to the database, because the database is being maintained by the providers.

    System.Data.SqlClient.SqlException (0x80131904): A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The specified network name is no longer available.) ---> System.ComponentModel.Win32Exception (0x80004005): The specified network name is no longer available.
    

    We can see in the logs that Umbraco is trying to boot and etablish connection every now and then, but keep gettin this error:

    Umbraco.Core.Exceptions.BootFailedException: Boot failed. -> System.Data.SqlClient.SqlException: A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The specified network name is no longer available.))
    

    The connection works again after we restart the appool or bumb the web.config, which i guess is also a restart.

    We have an ongoing dialog with the providers about this, because i think its their responsibility. But they say its an faul in Umbraco CMS and that's Umbraco CMS that should handle it.

    My question is if its the Umbraco Application Task to make sure to reetablish the connection, by what ever means or is it the providers Task?

  • Bo Jacobsen 606 posts 2404 karma points
    May 02, 2022 @ 07:21
    Bo Jacobsen
    0

    What i could google was that the connection to the database remains valid in the connection pool of one's application and the only way to refresh it is to restart the app pool.

  • Bo Jacobsen 606 posts 2404 karma points
    May 11, 2023 @ 11:29
    Bo Jacobsen
    0

    Almost a year after, we got another connection issue after the database was being restartet.

    The database was restartet about 5 am. Then the webapplication threw this error every 2nd second, until we bumb the web config at about 11 am.

    System.Data.SqlClient.SqlException (0x80131904): SHUTDOWN is in progress.
    Login failed for user 'xxx'.
    Cannot continue the execution because the session is in the kill state.
    A severe error occurred on the current command.  The results, if any, should be discarded.
       at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
       at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
       at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
       at System.Data.SqlClient.TdsParser.TdsExecuteTransactionManagerRequest(Byte[] buffer, TransactionManagerRequestType request, String transactionName, TransactionManagerIsolationLevel isoLevel, Int32 timeout, SqlInternalTransaction transaction, TdsParserStateObject stateObj, Boolean isDelegateControlRequest)
       at System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransactionYukon(TransactionRequest transactionRequest, String transactionName, IsolationLevel iso, SqlInternalTransaction internalTransaction, Boolean isDelegateControlRequest)
       at System.Data.SqlClient.SqlInternalConnection.BeginSqlTransaction(IsolationLevel iso, String transactionName, Boolean shouldReconnect)
       at System.Data.SqlClient.SqlConnection.BeginTransaction(IsolationLevel iso, String transactionName)
       at System.Data.SqlClient.SqlConnection.BeginDbTransaction(IsolationLevel isolationLevel)
       at StackExchange.Profiling.Data.ProfiledDbConnection.BeginDbTransaction(IsolationLevel isolationLevel) in C:\projects\dotnet\src\MiniProfiler.Shared\Data\ProfiledDbConnection.cs:line 151
       at NPoco.Database.BeginTransaction(IsolationLevel isolationLevel)
       at Umbraco.Core.Scoping.Scope.get_Database() in D:\a\1\s\src\Umbraco.Core\Scoping\Scope.cs:line 253
       at Umbraco.Core.Sync.DatabaseServerMessenger.BootInternal() in D:\a\1\s\src\Umbraco.Core\Sync\DatabaseServerMessenger.cs:line 161
       at System.Lazy`1.CreateValue()
       at System.Lazy`1.LazyInitValue()
       at Umbraco.Web.BatchedDatabaseServerMessenger.<.ctor>b__3_0() in D:\a\1\s\src\Umbraco.Web\BatchedDatabaseServerMessenger.cs:line 48
       at System.Lazy`1.CreateValue()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Lazy`1.get_Value()
       at Umbraco.Web.PublishedCache.NuCache.PublishedSnapshotService.<EnsureCaches>b__36_0() in D:\a\1\s\src\Umbraco.Web\PublishedCache\NuCache\PublishedSnapshotService.cs:line 245
       at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory)
       at Umbraco.Web.PublishedCache.NuCache.PublishedSnapshotService.EnsureCaches() in D:\a\1\s\src\Umbraco.Web\PublishedCache\NuCache\PublishedSnapshotService.cs:line 210
       at Umbraco.Web.PublishedCache.NuCache.PublishedSnapshotService.CreatePublishedSnapshot(String previewToken) in D:\a\1\s\src\Umbraco.Web\PublishedCache\NuCache\PublishedSnapshotService.cs:line 1109
       at System.Lazy`1.CreateValue()
       at System.Lazy`1.LazyInitValue()
       at Umbraco.Web.UmbracoInjectedModule.EnsureHasContent(UmbracoContext context, HttpContextBase httpContext) in D:\a\1\s\src\Umbraco.Web\UmbracoInjectedModule.cs:line 234
       at Umbraco.Web.UmbracoInjectedModule.EnsureUmbracoRoutablePage(UmbracoContext context, HttpContextBase httpContext) in D:\a\1\s\src\Umbraco.Web\UmbracoInjectedModule.cs:line 172
       at Umbraco.Web.UmbracoInjectedModule.ProcessRequest(HttpContextBase httpContext) in D:\a\1\s\src\Umbraco.Web\UmbracoInjectedModule.cs:line 111
       at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
    ClientConnectionId:a3db2f73-c2ae-4367-b937-b27521de344b
    Error Number:6005,State:1,Class:14
    

    Do anyone have any ideer if this is a database issue or if there is something we can do to force an application restart when this error occours?

  • Asembli 85 posts 259 karma points
    Sep 12, 2024 @ 05:50
    Asembli
    0

    It is not a solution, but it is a contribution to the forum if someone has a solution. I have the same problem and can't find a solution within Umbraco or core itself. The connection string is not terminated by itself - it is terminated when regular updates are made on the server. At that time, the apppools are raised, but since the first 'ping' to sql is unsuccessful, even when sql is set up, it still shows an error. Then I have to manually recycle the apppools. The sysadmin suggested making a command to recycle all apppools after each update after a certain timeout. It's an ugly hack, but it's worth a try...

    Regards

  • Bo Jacobsen 606 posts 2404 karma points
    Sep 12, 2024 @ 09:24
    Bo Jacobsen
    0

    Hi Asembli.

    What we ended up doing was making the IIS dependent on SQL SERVER on startup, so we ensure the SQL SERVER is running before the IIS starts.

  • Nijaz Hameed 38 posts 173 karma points
    16 days ago
    Nijaz Hameed
    0

    used the below powershell script and used to execute when server restarts

    # Wait until SQL Server is running, then start IIS
    $serviceName = "MSSQLSERVER"
    $maxRetries = 10
    $retries = 0
    $serviceRunning = $false
    
    while ($retries -lt $maxRetries -and !$serviceRunning) {
        $service = Get-Service -Name $serviceName -ErrorAction SilentlyContinue
        if ($service -and $service.Status -eq 'Running') {
            $serviceRunning = $true
        } else {
            Write-Host "Waiting for SQL Server to start..."
            Start-Sleep -Seconds 5
        }
        $retries++
    }
    
    if ($serviceRunning) {
        # Start IIS service after SQL Server is running
        Start-Service 'W3SVC'
        Write-Host "IIS started successfully."
    } else {
        Write-Host "SQL Server did not start in time. IIS will not be started."
    }
    
  • Nijaz Hameed 38 posts 173 karma points
    17 days ago
    Nijaz Hameed
    0

    Could you kindly explain how you accomplished this?

Please Sign in or register to post replies

Write your reply to:

Draft