Firebird ADO.NET-Provider connection pool error on connection lost
See original GitHub issueFirst, this is not a linq2DB error, it is a tip for a workaround caused by the current Firebird ADO.NET provider (Version 4.6.0.0 - 5.12.1.0) If you are working with connection pools and your connection is lost e.g. because the Firebird server is closed, the pooled connection is still marked as ‘opened’. So every database access will create an Exception (FBException) ‘Error reading data from the connection’. So if the Firebird server is accessible again you still cannot access it because the old connection will be used!
One solution is to disable pooling. I don’t like this because of performance reduction.
Another solution is to handle it in the OnTrace Action.:
DataConnection.OnTrace = delegate(TraceInfo info)
{
try
{
// First time access, if no connection has been ever established, this will throw an error!
var conn = (FbConnection)info.DataConnection?.Connection;
var fbException = info.Exception as FbException;
// The error code stands for 'Error reading data from the connection'
if (fbException != null && fbException.ErrorCode == 335544726)
{
// Clear all pooled connections, because the connection to the database is lost!
FbConnection.ClearAllPools();
}
}
catch (Exception ex)
{
// No database connection was ever opened!
return;
}
};
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Error MaxPoolSize on Firebird database
In connection to the database I use a pool of connections and Firebird database. I use FirebirdSql.Data.FirebirdClient version 2.6.5.0.
Read more >ADO.NET Connection Pooling with C# Code Examples ...
This tutorial describes how reusing pooled connections, instead of creating new connections, can improve .NET application performance.
Read more >14.2 Connections Pool Management
Configures the maximum number of idle connections in the pool. The default value is set using the parameter ExtConnPoolSize in firebird. conf ....
Read more >FirebirdSql.Data.Common.IscException: Error writing ...
This error happens when the firebird server crashes or some network interruption. Connection pooling usually makes this worse since it keeps old connections ......
Read more >Idle database connection lost - linux
When operating interactively using Firebird Maestro (relevance unknown), after I get this error I tell Maestro to disconnect. I am then able to ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This works:
In your context costructor just call:
this.RetryPolicy = new FbRetryPolicy();
Never tried that, but there many unit tests. https://github.com/linq2db/linq2db/blob/cf160d92b7062d1af7581abeb7185b20a0fdde94/Tests/Linq/Data/RetryPolicyTest.cs