November Happy Hour will be moved to Thursday December 5th.

EPiServer.DataAbstraction.ScheduledJob errors with: ExecuteNonQuery requires an open and available Connection

Vote:
 

We are getting this error in our logs intermittently about 50 times a day (see below). It is not customer impacting, because it seems to be related to executing background scheduled jobs. Has anyone experienced this issue or can give us some insight into what the problem might be?

We are running Episerver CMS 8.3.0.

Please advise, thank you

	Exception occurred. - System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. ---> System.InvalidOperationException: ExecuteNonQuery requires an open and available Connection. The connection's current state is closed.
   at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at EPiServer.Data.Providers.SqlDatabaseHandler.<>c__DisplayClass4.<ExecuteTransaction>b__3()
   at EPiServer.Data.Providers.SqlDatabaseHandler.<>c__DisplayClass7`1.<ExecuteTransaction>b__6()
   at EPiServer.DataAbstraction.ScheduledJobRepository.UpdateRunningState(Guid id, Boolean isRunning)
   at EPiServer.DataAbstraction.ScheduledJob.<>c__DisplayClass9.<InternalExec>b__5()
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.InvalidOperationException: ExecuteNonQuery requires an open and available Connection. The connection's current state is closed.
   at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at EPiServer.Data.Providers.SqlDatabaseHandler.<>c__DisplayClass4.<ExecuteTransaction>b__3()
   at EPiServer.Data.Providers.SqlDatabaseHandler.<>c__DisplayClass7`1.<ExecuteTransaction>b__6()
   at EPiServer.DataAbstraction.ScheduledJobRepository.UpdateRunningState(Guid id, Boolean isRunning)
   at EPiServer.DataAbstraction.ScheduledJob.<>c__DisplayClass9.<InternalExec>b__5()
   at System.Threading.Tasks.Task.Execute()<---
#217288
Feb 20, 2020 10:59
Vote:
 

Would you mind adding your scheduled job code here? Are you executing a SQL command in the scheduled job? My guess is that when the task finishes the connection to SQL is already closed throwing this error. Maybe a SQL profiler may help?

#217312
Feb 20, 2020 17:25
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.