首页 新闻 赞助 找找看

System.Data.SqlClient.SqlException: Timeout 时间已到

0
[待解决问题]

用EF4.0持久化数据到数据库时偶尔报数据库超时的错误,这是什么原因呢? 内容如下:

 

2016-12-06 09:40:14,835 [30] ERROR - An error occurred while updating the entries. See the inner exception for details.
System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.Data.Entity.Core.UpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.Data.SqlClient.SqlException: Timeout 时间已到。在操作完成之前超时时间已过或服务器未响应。
语句已终止。 ---> System.ComponentModel.Win32Exception: 等待的操作过时。
--- 内部异常堆栈跟踪的结尾 ---
在 System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
在 System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
在 System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
在 System.Data.SqlClient.SqlDataReader.get_MetaData()
在 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
在 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
在 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
在 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
在 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
在 System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
在 System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
在 System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
在 System.Data.Entity.Core.Mapping.Update.Internal.DynamicUpdateCommand.Execute(Dictionary`2 identifierValues, List`1 generatedValues)
在 System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()
--- 内部异常堆栈跟踪的结尾 ---
在 System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()
在 System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
在 System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction)
在 System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
在 System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction)
在 System.Data.Entity.Internal.InternalContext.SaveChanges()
--- 内部异常堆栈跟踪的结尾 ---

bluthly的主页 bluthly | 菜鸟二级 | 园豆:202
提问于:2016-12-06 11:17
< >
分享
所有回答(1)
0

你最后的sql语句执行时间过长导致的。在sqlprofiler中检查下sql为什么会执行偏慢。

Daniel Cai | 园豆:10424 (专家六级) | 2016-12-06 11:20

谢谢你的回复,原因已找到!日志库初始化空间设置过大,自增长设置为10%,当超过初始值后每次分配的空间过大操作时备份操作日志比较慢超时导致的!

支持(0) 反对(0) bluthly | 园豆:202 (菜鸟二级) | 2017-01-18 09:22

@bluthly: 那你改下增长模式,不要按百分比,按大小。

支持(0) 反对(0) Daniel Cai | 园豆:10424 (专家六级) | 2017-01-18 10:22
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册