You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using BLToolkit 4.2 together with System.Data.SQLite 1.0.93. I've noticed that sometimes DB file remains locked after running complex queries. After some debugging I've found that an SQLiteConnection remains open. Further debugging showed that:
When BLToolkit executes a subquery, it clones the root DataContextInfo (see QueryContext.GetDataContext()) which in turn clones DbManager.
DbManager clones connection via DataProvider (see DataProviderBase.CloneConnection())
System.Data.SQLite's SQLiteConnection.Clone() creates a new connection and opens it if the original connection is open:
Nested DbManager's _closeConnection flag is never set because connection is already open and OpenConnection() is not executed.
When the root DbManager is disposed it correctly disposes its own connection and the nested DbManager, but the cloned connection is not closed/disposed as _closeConnection == false (see DbManager.Close()).
Consequently, new connection was created in DbManager, but was not disposed in it.
The following small sample demonstrates this behavior:
This helped with my issue but I am not sure if it may affect other scenarios/data provider types, and I'm not able to run unit test properly as I don't have proper environment with different databases configured. Please advise if this is an acceptable solution.
The text was updated successfully, but these errors were encountered:
I'm using BLToolkit 4.2 together with System.Data.SQLite 1.0.93. I've noticed that sometimes DB file remains locked after running complex queries. After some debugging I've found that an SQLiteConnection remains open. Further debugging showed that:
Consequently, new connection was created in DbManager, but was not disposed in it.
The following small sample demonstrates this behavior:
Program.cs
init.sql
My workaround was to check if connection is already open after cloning and set DbManager._closeConnection flag if it is:
This helped with my issue but I am not sure if it may affect other scenarios/data provider types, and I'm not able to run unit test properly as I don't have proper environment with different databases configured. Please advise if this is an acceptable solution.
The text was updated successfully, but these errors were encountered: