-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Hi!
I made a PR to support storing guids as blobs #739
When running the tests, I noticed, that the async tests fail - except of the very first one.
The exception that causes the UTs to fail is
SetUp : System.IO.IOException : The process cannot access the file '......async.db' because it is being used by another process
Note, that I am running these tests with
USE_SQLITEPCL_RAW
it seems that everything is disposed correctly in the tests.
Then I found [this issue on stackoverflow] (https://stackoverflow.com/questions/8511901/system-data-sqlite-close-not-releasing-database-file) which sounded pretty similar.
Explanation:
What happens when you call SQLiteConnection.Close() is that (along with a number of checks and other things) the SQLiteConnectionHandle that points to the SQLite database instance is disposed. This is done through a call to SQLiteConnectionHandle.Dispose(), however this doesn't actually release the pointer until the CLR's Garbage Collector performs some garbage collection. Since SQLiteConnectionHandle overrides the CriticalHandle.ReleaseHandle() function to call sqlite3_close_interop() (through another function) this does not close the database.
So I tried out their solution, which is adding a call to "GC.Collect" in order to be able to delete the file.
[SetUp]
public void SetUp()
{
SQLite.SQLiteConnectionPool.Shared.Reset ();
#if NETFX_CORE
//...
#else
_connectionString = Path.Combine (Path.GetTempPath (), DatabaseName);
_path = _connectionString;
GC.Collect ();
GC.WaitForPendingFinalizers ();
System.IO.File.Delete (_path);
#endif
}
This actually did the trick, however I am not sure in how to proceed...
@ericsink and @praeclarum:
- is this a known issue of SQLite.PCL.raw?
- Is it intended? If so, how do I fix it
- I tried to upgrade to SQLitePCLRaw v1.1.11 but that did not change anything