Open
Description
In production, our application sometimes randomly starts to malfunction.
I've noticed that once a problem has occurred, the behavior is no longer stable.
Could it be that connections are being put back into the pool when an exception has occurred, leaving the connection in an incorrect state?
In the FirebirdClient sources, in the FbConnection Close[Async] functions, I see for example:
var broken = _innerConnection.Database.ConnectionBroken;
FbConnectionPoolManager.Instance.Release(_innerConnection, !broken);
But ConnectionBroken / IOFailed is only set to True on an IOException.
For example, in ReadAsync:
catch (IOException)
{
IOFailed = true;
throw;
}
Shouldn't other exceptions also be handled? In our case, it seems that OperationCanceledException is the one that occurs.
Thanks
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
cincuranet commentedon Apr 3, 2025
Other exceptions should in general be OK, because the low level code can recover from it and then it is about what the developer is going to do next. But sending/receiving bytes should still work.
Do you have a repro?
ftrl commentedon Apr 3, 2025
Alas no, impossible to reproduce.
The only thing that made me think of it was the following stackTrace:
cincuranet commentedon Apr 3, 2025
I don't see how this related to what you initially described... This looks like a regular exception when
CancelationToken
is used.ftrl commentedon Apr 3, 2025
Yes, but in this case, the connection is put back into the Pool.
And I thought it might be in an unstable state.
But if you don't think it's possible, okay.
cincuranet commentedon Apr 3, 2025
Can you create repro that shows that the connection does not work after it is taken from the pool (and possibly the action that is going to happen is retried)? It is possible that there's a case that fails.
ftrl commentedon Apr 3, 2025
Unfortunately, I can't see how to do this. Our application is very large and has many entry points (api). And errors occur without any apparent rule.
Firebird calls are made via an orm (linq2db).
I only get the exception globally, when it occurs (I no longer have the connection at that time).
But nevertheless, I've noticed that these problems we're experiencing are “recent” and concomitant with the systematic implementation of async functions with a CancellationToken. But here again, nothing is certain.
I know, it doesn't help!
mrotteveel commentedon Apr 3, 2025
I can see how cancelling in the middle of an IO operation would leave the connection in an inconsistent state (what has been sent, what has been received?)
cincuranet commentedon Apr 3, 2025
Ah right. Not every
CancellationToken
is registered and handled through server. I have to check the code, what was actually my idea in these cases. I no longer remember.ftrl commentedon Apr 3, 2025
Maybe I can just try to compile FirebirdClient (the version we are using) by replacing :
by
and rapidly test the dll in production.
cincuranet commentedon Apr 11, 2025
Related to #945.