New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FbConnection.CreateDatabase does not always throw exceptions when it cannot create the database [DNET398] #401
Comments
Commented by: @cincuranet I'm unable to reproduce this bug on 2.6.5 and 2.7.0. The #3 throws: |
Modified by: @cincuranetstatus: Open [ 1 ] => In Progress [ 3 ] |
Commented by: Fernando Nájera (fernandonajera) Thanks for your comment. I tried to replicate it again, and I couldn't... until I remembered that I have upgraded Firebird in my machine recently. The error is reproducible against Firebird 2.1.4, but not against 2.5.1 (those are the two versions we use). Test program (console):
-- Fb214 Provider 260 .NET 3.5 --------------------------------------------- Tests with Firebird 2.5.1 -- Fb251 Provider 260 .NET 3.5 --------------------------------------------- As we have users that might be using the old version of Firebird (2.1.x), we need to ensure that our code works as expected with them. Interestingly, as you can see, 2.6.0 did work in all the situations; but 2.6.5 and 2.7.0 don't. |
Commented by: Fernando Nájera (fernandonajera) Updated affected versions and the environment (version of Firebird *is* relevant) |
Modified by: Fernando Nájera (fernandonajera)Version: 2.7 [ 10431 ] environment: Tested against Firebird 2.1.4; apparently it works if used against Firebird 2.5.1 |
Commented by: @cincuranet Same on 2.1.3. But even if I force provider to take exactly same code path for 2.1 as for 2.5 the behavior differs (on 2.7.5 provider). BTW the "invalid database handle (no active connection)" is just a side-effect of already fixed bug. The exception should be same. |
Commented by: @cincuranet Looks like the Firebird 2.1.x doesn't return the error. I just get a valid response, without any exception. I asked CORE devs, but no reply. Probably just an improvement in 2.5.x and nobody remembers. The "invalid database handle (no active connection)" that was there was a bug in my code. It looked like it is working, but it was failing (but for another reason). |
Modified by: @cincuranetstatus: In Progress [ 3 ] => Resolved [ 5 ] resolution: Won't Fix [ 2 ] Fix Version: vNext [ 10704 ] |
Submitted by: Fernando Nájera (fernandonajera)
Consider the following code:
string file = @"X:\Test.fdb";
File.Delete (file);
string cnnStr = @"character set=UTF8;connection lifetime=15;user id=SYSDBA;password=masterkey;initial catalog=" + file + @";data source=localhost;dialect=3;pooling=False;min pool size=0;max pool size=50;packet size=8192;server type=Default";
FbConnection.CreateDatabase (cnnStr, 8192, true, false);
FbConnection.CreateDatabase (cnnStr, 8192, true, false);
Test #1: run the code as-is
In 2.6.0.0, the second CreateDatabase fails with 'I/O error during "CreateFile (create)" operation for file "X:\TEST.FDB" // Error while trying to create file', which is fine.
In 2.6.5.0, the second CreateDatabase fails with 'I/O error during "CreateFile (create)" operation for file "X:\TEST.FDB" // Error while trying to create file', which is fine.
Test #2: run up to the first FbConnection, then connect to the database using another process (e.g. via isql), and while connected, run the second FbConnection
In 2.6.0.0, the second CreateDatabase fails with 'invalid database handle (no active connection)', which is good enough for me.
In 2.6.5.0, the second CreateDatabase does not throw any exception!
Test #3: change the code above so instead of the two CreateDatabase calls you have now this:
FbConnection.CreateDatabase (cnnStr, 8192, true, false);
using (FbConnection cnn = new FbConnection (cnnStr))
{
cnn.Open ();
FbConnection.CreateDatabase (cnnStr, 8192, true, false);
}
In 2.6.0.0, the second CreateDatabase fails with 'invalid database handle (no active connection)', which is good enough for me.
In 2.6.5.0, the second CreateDatabase does not throw any exception!
The bottom line is, if the database has any active connection (by the same or by another process), CreateDatabase does not fail in 2.6.5.0! This is a change of behaviour against 2.6.0.0, and in my opinion is a bug - CreateDatabase should create a database, or fail.
I have put the priority to Critical, because this behavior can effectively lead to crashes - the call does not fail, so you think you have created a new, empty database, when in fact you are reusing an existing database!
The text was updated successfully, but these errors were encountered: