System.Data.SQLite

Login
This project makes use of Eagle, provided by Mistachkin Systems.
Eagle: Secure Software Automation
2011-10-04
09:19 Ticket [ac47dd230a] Not Compatible with MSTest (concurrent App Domains) status still Closed with 2 other changes artifact: 8ead5f22bd user: mistachkin
08:10 Closed ticket [ac47dd230a]. artifact: 35e01feb19 user: mistachkin
08:05
Prevent the SQLiteLog.DomainUnload method from being added multiple times to the AppDomain.DomainUnload event, ticket [0d5b1ef362]. Stop trying to configure the SQLite logging interface in non-default AppDomains, ticket [ac47dd230a]. check-in: 3054af47e2 user: mistachkin tags: trunk
04:42 Ticket [ac47dd230a] Not Compatible with MSTest (concurrent App Domains) status still Open with 1 other change artifact: 698862c881 user: mistachkin
04:20 Ticket [ac47dd230a]: 5 changes artifact: 47b4ac891e user: anonymous
02:02 New ticket [ac47dd230a]. artifact: 9cd3623c27 user: anonymous

Ticket Hash: ac47dd230ae846e0f3d566a6f9c3d9dd89ffade5
Title: Not Compatible with MSTest (concurrent App Domains)
Status: Closed Type: Code_Defect
Severity: Important Priority: Immediate
Subsystem: Logging Resolution: Fixed
Last Modified: 2011-10-04 09:19:54
Version Found In: 1.0.75.0
Description:
The new logging code in 1.0.75.0 seems to be causing (me) problems when using SQLite from within MSTest.

I think the problem is related to MSTest's usage of multiple App Domains (one per assembly containing unit tests).

SQLiteLog.Initialize is getting a SQLITE_MISUSE error when it tries to set the log callback function. From what I can tell looking at the SQLite source, the most likely cause of that is that the native library has been initialized (and not fully shutdown?)


anonymous added on 2011-10-04 04:20:23 UTC:
Did some more debugging, and FWIW, the problem appears to be that MSTest isn't shutting down the first app domain before starting tests in the second one.

Not sure if this is fixable within the SQLite library.

A workaround would be to call new SQLiteConnection().Shutdown() in an AssemblyInitialize method, except that won't work because the SQLiteConnection constructor will fail in the SQLiteLog initialization before the Shutdown call can be made.


mistachkin added on 2011-10-04 04:42:03 UTC:
Since AppDomains are totally isolated from each other (i.e. they have no knowledge of each other), this is going to be difficult to solve in managed code.


mistachkin added on 2011-10-04 08:10:08 UTC:
Fixed by check-in [3054af47e2].

Basically, the "fix" for this is to prevent the SQLiteLog class from being initialized in non-default AppDomains unless the special environment variable "Force_SQLiteLog" is set to manually override this new behavior. This is not an ideal fix; however, it seems reasonable and it is the best that can done without having a reference counting mechanism in the SQLite core library itself.