Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
664 views
in Technique[技术] by (71.8m points)

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

Today I did a larger data import into a firebird 2.5.6 database and I got this exception:

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:UsersJiriDocumentsdevelNETProviderworkingProvidersrcFirebirdSql.Data.FirebirdClientClientManagedVersion10GdsDatabase.cs:Zeile 641.
   bei FirebirdSql.Data.Client.Managed.Version10.GdsDatabase.ReadResponse() in C:UsersJiriDocumentsdevelNETProviderworkingProvidersrcFirebirdSql.Data.FirebirdClientClientManagedVersion10GdsDatabase.cs:Zeile 673.
   bei FirebirdSql.Data.Client.Managed.Version10.GdsDatabase.ReadGenericResponse() in C:UsersJiriDocumentsdevelNETProviderworkingProvidersrcFirebirdSql.Data.FirebirdClientClientManagedVersion10GdsDatabase.cs:Zeile 681.
   bei FirebirdSql.Data.Client.Managed.Version11.GdsStatement.Prepare(String commandText) in C:UsersJiriDocumentsdevelNETProviderworkingProvidersrcFirebirdSql.Data.FirebirdClientClientManagedVersion11GdsStatement.cs:Zeile 80.
   bei FirebirdSql.Data.FirebirdClient.FbCommand.Prepare(Boolean returnsSet) in C:UsersJiriDocumentsdevelNETProviderworkingProvidersrcFirebirdSql.Data.FirebirdClientFirebirdClientFbCommand.cs:Zeile 1169.
   bei FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteCommand(CommandBehavior behavior, Boolean returnsSet) in C:UsersJiriDocumentsdevelNETProviderworkingProvidersrcFirebirdSql.Data.FirebirdClientFirebirdClientFbCommand.cs:Zeile 1190.
   bei FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader(CommandBehavior behavior) in C:UsersJiriDocumentsdevelNETProviderworkingProvidersrcFirebirdSql.Data.FirebirdClientFirebirdClientFbCommand.cs:Zeile 527.
   --- Ende der internen Ausnahmestapelüberwachung ---
   bei FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader(CommandBehavior behavior) in C:UsersJiriDocumentsdevelNETProviderworkingProvidersrcFirebirdSql.Data.FirebirdClientFirebirdClientFbCommand.cs:Zeile 533.
   bei FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteDbDataReader(CommandBehavior behavior) in C:UsersJiriDocumentsdevelNETProviderworkingProvidersrcFirebirdSql.Data.FirebirdClientFirebirdClientFbCommand.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)

Can someone explain what this too many open handles to database means? I never saw this before and searching in google only shows 1 old entry.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The error isc_too_many_handles or error 335544761 means what it says: you use too many handles.

Looking at the Firebird 3 code, server.cpp (search for isc_too_many_handles), this error is raised if Firebird cannot allocate a handle for a statement, transaction, blob, or 'request' because you already have 65000 (MAX_OBJCT_HANDLES) handles allocated and in use on a single connection. Note that this number is for all handles on the connection together (not per type).

This can happen if you do too much of the following:

  • create new statement handles without dropping (closing) statement handles you no longer need,
  • start transactions but never commit or rollback (which deallocates the handle),
  • open blobs without closing them (or opening a lot of blobs at once), and
  • start 'requests' without deallocating them.

    AFAIK these 'requests' are used for embedded SQL support and some internal parts of Firebird itself; I'm not exactly sure how and when they are used, so I can't really comment on them. I guess it is not very likely the cause, but maybe when you already have a lot of statements, blobs and transactions these can be the final drop.

You might want to inspect your code for resource leaks, but as you seem to be using Entity Framework, it might also be that the Firebird .net entity framework support or ADO.net driver does something wrong. If you can reproduce it consistently, and you are sure you are closing resources timely, you might want to report a bug (with all necessary code + database to reproduce) on http://tracker.firebirdsql.org/browse/DNET


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...