entity-framework - FirebirdSql.Data.FirebirdClient.FbException : too many open handles to database

标签 entity-framework entity-framework-6 firebird

今天我将更大的数据导入到 firebird 2.5.6 数据库中,我得到了这个异常:

System.Data.Entity.Core.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. ---> FirebirdSql.Data.FirebirdClient.FbException: too many open handles to database ---> FirebirdSql.Data.Common.IscException: too many open handles to database
   bei FirebirdSql.Data.Client.Managed.Version10.GdsDatabase.ProcessResponse(IResponse response) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\Client\Managed\Version10\GdsDatabase.cs:Zeile 641.
   bei FirebirdSql.Data.Client.Managed.Version10.GdsDatabase.ReadResponse() in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\Client\Managed\Version10\GdsDatabase.cs:Zeile 673.
   bei FirebirdSql.Data.Client.Managed.Version10.GdsDatabase.ReadGenericResponse() in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\Client\Managed\Version10\GdsDatabase.cs:Zeile 681.
   bei FirebirdSql.Data.Client.Managed.Version11.GdsStatement.Prepare(String commandText) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\Client\Managed\Version11\GdsStatement.cs:Zeile 80.
   bei FirebirdSql.Data.FirebirdClient.FbCommand.Prepare(Boolean returnsSet) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\FirebirdClient\FbCommand.cs:Zeile 1169.
   bei FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteCommand(CommandBehavior behavior, Boolean returnsSet) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\FirebirdClient\FbCommand.cs:Zeile 1190.
   bei FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader(CommandBehavior behavior) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\FirebirdClient\FbCommand.cs:Zeile 527.
   --- Ende der internen Ausnahmestapelüberwachung ---
   bei FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader(CommandBehavior behavior) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\FirebirdClient\FbCommand.cs:Zeile 533.
   bei FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteDbDataReader(CommandBehavior behavior) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\FirebirdClient\FbCommand.cs:Zeile 639.
   bei System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   bei System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<Reader>b__c(DbCommand t, DbCommandInterceptionContext`1 c)
   bei System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
   bei System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
   bei System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)
   bei System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
   bei System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
   --- Ende der internen Ausnahmestapelüberwachung ---
   bei System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
   bei System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
   bei System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__6()
   bei System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
   bei System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__5()
   bei System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute[TResult](Func`1 operation)
   bei System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
   bei System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0()
   bei System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
   bei System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   bei System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__1[TResult](IEnumerable`1 sequence)
   bei System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)
   bei System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
   bei System.Data.Entity.Internal.Linq.DbQueryProvider.Execute[TResult](Expression expression)
   bei System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)

有人能解释一下这是什么too many open handles to database方法?我以前从未见过这个和 searching in google只有shows 1 old entry .

最佳答案

错误 isc_too_many_handles或错误 335544761 意味着它所说的:您使用了太多句柄。

查看 Firebird 3 代码, server.cpp (搜索 isc_too_many_handles ),如果 Firebird 无法为语句、事务、blob 或“请求”分配句柄,则会引发此错误,因为您已经在单个连接上分配和使用了 65000 个( MAX_OBJCT_HANDLES )句柄。请注意,此数字用于连接上的所有句柄(不是每个类型)。

如果您执行以下过多操作,可能会发生这种情况:

  • 创建新的语句句柄而不删除(关闭)不再需要的语句句柄,
  • 启动事务但从不提交或回滚(释放句柄),
  • 打开 blob 而不关闭它们(或一次打开大量 blob),以及
  • 开始“请求”而不释放它们。

    AFAIK 这些“请求”用于嵌入式 SQL 支持和 Firebird 本身的一些内部部分;我不确定它们是如何以及何时使用的,所以我无法真正评论它们。我想这不太可能是原因,但也许当你已经有很多语句、blob 和事务时,这些可能是最后的下降。

  • 您可能想要检查您的代码是否存在资源泄漏,但由于您似乎在使用 Entity Framework ,也可能是 Firebird .net Entity Framework 支持或 ADO.net 驱动程序做错了什么。如果您可以始终如一地重现它,并且您确定及时关闭资源,您可能希望在 http://tracker.firebirdsql.org/browse/DNET 上报告一个错误(包含所有必要的代码 + 要重现的数据库)。

    关于entity-framework - FirebirdSql.Data.FirebirdClient.FbException : too many open handles to database,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39148222/

    相关文章:

    c# - 使用 Entity Framework 将记录插入表中

    c# - 锁定数据库,使用 C#

    sql-server - 创建临时表并同时存储执行命令的结果

    c++ - 如何检测浮点表示错误 ...99999... 或 ...00000... 并在 C++ 中更正它们

    sql - Firebird 数据类型列字段不正确

    c# - MySQL Entity Framework 按日期分组和选择

    C# Entity Framework 自定义约束

    asp.net - 如何在 ASP.NET 5 和 EF7 的代码优先方法中设置可选字段

    c# - 如何在代码中添加 Entity Framework 6 提供程序?

    Firebird 4 使用 gsec 或 isql 时出现 "Incompatible data type"错误