System.Data.SQLite

Login
This project makes use of Eagle, provided by Mistachkin Systems.
Eagle: Secure Software Automation
Ticket Hash: 8e3f4a3dea72d97ef1fb97be356f64db2e7536c3
Title: Connections remain open when using with web server
Status: Closed Type: Incident
Severity: Important Priority: Medium
Subsystem: LINQ Resolution: External_Bug
Last Modified: 2020-10-29 02:38:33
Version Found In: 1.0.112
User Comments:
anonymous added on 2020-04-15 11:31:09:

Hi guys.

I have a problem with SQLite that is making me dizzy.

The environment is rather complex. I uses an IIS server that access a SQLite database using Entity Framework EF6 for Dot.Net.

The specific provider i use is System.Data.SQLite.EF6

(https://system.data.sqlite.org/)

As far as i access the database writing something to it, the DB remain locked, and the only way to unlock it is bringing down IIS session!

I know some "connection pool" are probably in use, and this is good, because i always access the DB using disconnected recordset via WebApi, but i wonder if exist a way, a low level call, whatseover, to ABRUPTALLY CLOSE/KILL ALL DB CONNECTIONS and release the file, for maintenance purposes.

Typical usage pattern is with "Using" c# statement, so i'm pretty sure everything is disposed, including the EF6 connection

public List<behaviour> LoadBehaviours()
{
    using (var ShapeDb = ShapeDbEntities(true))
    {
        ShapeDb.behaviours.Load();
        return new List<behaviour>(ShapeDb.behaviours);
    }
}

I have attempted to close the collection pool using this:

public static void CloseAllConnectionPools()
{
    if (SQLiteConnection.ConnectionPool!=null)
    {
        SQLiteConnection.ConnectionPool.ClearAllPools();
    }
    SQLiteConnection.ClearAllPools();
}

But this do not work.

Is it possible to drill down to SQLite core api and force releasing of pending connections ??

Regards, Paolo Marani, Italy


mistachkin added on 2020-04-18 13:14:43:
The EntityFramework is known to hold connections (and other database objects)
open in some circumstances.  This would prevent SQLite (and System.Data.SQLite)
from cleaning up those resources.

There is not much that System.Data.SQLite can do to prevent this issue and there
is no way to forcibly close a connection without using the normal Close methods.

Also, closing a connection while other System.Data.SQLite objects are using it is
not recommended.