Question

I am using azure sql with many quartz windows service which runs every 2 mins. I sometimes get following error

Message:An error occurred while executing the command definition. See the inner 
 exception for details.|System.Data.SqlClient.SqlException (0x80131904): A 
 transport-level error has occurred when receiving results from the server. 
 (provider: Session Provider, error: 19 - Physical connection is not usable) at 
 System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean 
 breakConnection, Action`1 wrapCloseInAction) at 
 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, 
 Boolean breakConnection, Action`1 wrapCloseInAction) at 
 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject 
 stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at 
 System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject 
 stateObj, UInt32 error) at 
 System.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync() at 
 System.Data.SqlClient.TdsParserStateObject.TryReadNetworkPacket() at 
 System.Data.SqlClient.TdsParserStateObject.TryPrepareBuffer() at 
 System.Data.SqlClient.TdsParserStateObject.TryReadByte(Byte& value) at 
 System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand 
 cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, 
 TdsParserStateObject stateObj, Boolean& dataReady) at 
 System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() at 
 System.Data.SqlClient.SqlDataReader.get_MetaData() at 
 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior 
 runBehavior, String resetOptionsString) at 
 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, 
 RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& 
 task, Boolean asyncWrite, SqlDataReader ds) at 
 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, 
 RunBehavior runBehavior, Boolean returnStream, String method, 
 TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite) 
 at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, 
 RunBehavior runBehavior, Boolean returnStream, String method) at 
 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String 
 method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior 
 behavior) at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) 
 at 
 System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<>c__DisplayClass
 b.b__8() at 
 System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TInterc
 eptionContext,TResult](Func`1 operation, TInterceptionContext interceptionContext, 
 Action`1 executing, Action`1 executed) at 
 System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand 
 command, DbCommandInterceptionContext interceptionContext) at 
 System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavi
 or behavior) at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior 
 behavior) at 
 System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCo
 mmands(EntityCommand entityCommand, CommandBehavior behavior) 
 ClientConnectionId:9a85a9a9-69aa-4a68-8e05-e54adf5ac318

Any Idea how to resolve this? We are using EF 6.1 and open context in "using" block.

Was it helpful?

Solution

Found the answer here. While working with Azure SQL we should have logic to retry the database operation. EF 6.0 gives it out of the box

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top