Ticket Hash: | e30b820248e1ecdd839e462646f5c9fe5965d6df | ||
Title: | API called with finalized prepared statement | ||
Status: | Closed | Type: | Incident |
Severity: | Minor | Priority: | Blocker |
Subsystem: | Integration_Via_PInvoke | Resolution: | Fixed |
Last Modified: |
2014-02-07 01:05:47 11.27 years ago |
Created: |
2011-10-21 09:36:00 13.57 years ago |
Version Found In: | 1.0.77.0 |
Description: | ||||
When I call .Close() on the database connection, i see these errors:
SQLite error (21): API called with finalized prepared statement SQLite error (21): misuse at line 61617 of [3e0da808d2] SQLite error (21): API called with finalized prepared statement SQLite error (21): misuse at line 61617 of [3e0da808d2] SQLite error (21): API called with finalized prepared statement SQLite error (21): misuse at line 61617 of [3e0da808d2] SQLite error (21): API called with finalized prepared statement SQLite error (21): misuse at line 61617 of [3e0da808d2] SQLite error (21): API called with finalized prepared statement SQLite error (21): misuse at line 61617 of [3e0da808d2] Can I safely ignore them or what do they mean? mistachkin added on 2011-10-21 10:41:20 UTC: anonymous added on 2011-10-21 13:21:00 UTC: Do you have any idea what kind of problems can give these messages? I did not see them with the dll of PHX Software, and my code did not change. mistachkin added on 2011-10-22 00:30:21 UTC: anonymous added on 2011-10-22 16:33:42 UTC: I tried to debug it a little today, and whenever my code did some commits with parametrized inserts (.CreateParameter, .Parameters.Add, etc) I always see these messages upon .Close() of the db connection. So I think the parameters are already garbage collected by the .Net runtime, and the library is trying to dispose them for the second time? mistachkin added on 2011-11-06 21:10:11 UTC: anonymous added on 2011-11-10 21:49:06 UTC: - Dispose DbCommand object - Commit Transaction object - Dispose Transaction object When I change the order into: - Commit Transaction object - Dispose Transaction object - Dispose DbCommand object I don't see any error messages. anonymous added on 2011-11-13 02:21:38 UTC: Also, I found that I can reproduce the issue without transactions at all. When I open the database, do a single call to ExecuteReader(), and close the database, I see the same message if the DbCommand is already disposed or garbage collected. I will try to find some time to create some example code that reproduces the issue. mistachkin added on 2011-11-13 08:05:38 UTC: anonymous added on 2011-11-13 13:55:43 UTC: mistachkin added on 2011-11-13 21:30:24 UTC: Here is a link to the latest version of the test case I am working on for this issue: tkt-e30b820248.eagle You'll notice some C# code embedded in the test script, this is what I would like your opinion on. mistachkin added on 2011-11-13 21:52:18 UTC: anonymous added on 2011-11-14 11:56:41 UTC: class SqlDb { private DbConnection Con; void Open { Con = Fact.CreateConnection(); Con.Open(); } DbDatareader GetReader(string sCommand) { DbCommand Com = Con.CreateCommand(); Com.CommandText = sCommand; return Com.ExecuteReader(); } void Close() { Con.Close(); Con.Dispose(); } And the code that triggers the issue does this: void Example() { DbDatareader Read = SqlDb.GetReader(query) [WORK] Read.Close() SqlDb.Close() } So what I think what happens is that the original DbCommand is already disposed, since GetReader() only returns the DbDatareader, not the original command. Then when the database is closed, it cannot find the reference to DbCommand anymore? mistachkin added on 2011-11-14 23:50:33 UTC: anonymous added on 2011-11-16 01:10:13 UTC: mistachkin added on 2011-11-16 03:17:24 UTC: anonymous added on 2011-11-16 20:38:19 UTC: mistachkin added on 2011-11-17 00:48:58 UTC: anonymous added on 2011-11-17 11:33:56 UTC: Can you confirm they are absolutely harmless? Because we're delaying the shipment of the next version of our software on this, untill we know that it cannot introduce leaks or other problems. mistachkin added on 2011-11-17 21:04:34 UTC: anonymous added on 2011-11-18 17:55:34 UTC: SQLite error (21): misuse at line 110832 of [a499ae3835] Even on simply calling Connection.Open(), that should be easier to reproduce. mistachkin added on 2011-11-18 18:39:33 UTC: That message *is* harmless. It's part of a new check performed during initialization of the SQLiteLog class. Please ignore it. mistachkin added on 2011-11-18 18:43:37 UTC: Do you still see the *other* messages with the latest trunk code? mistachkin added on 2011-11-23 02:46:38 UTC: anonymous added on 2011-11-27 14:49:23 UTC: anonymous added on 2011-12-13 08:06:52 UTC: using(SQLiteConnection cn = new SQLiteConnection()) { cn.ConnectionString = ConnectionString; cn.Open(); { if(!string.IsNullOrEmpty(attachSqlQuery)) { using(DbCommand com = cn.CreateCommand()) { com.CommandText = attachSqlQuery; int x = com.ExecuteNonQuery(); //Debug.WriteLine("Attach: " + x); } } using(DbCommand com = cn.CreateCommand()) { com.CommandText = string.Format(finnalSqlSelect, pos.X, pos.Y, zoom, type); using(DbDataReader rd = com.ExecuteReader(System.Data.CommandBehavior.SequentialAccess)) { if(rd.Read()) { long length = rd.GetBytes(0, 0, null, 0, 0); byte[] tile = new byte[length]; rd.GetBytes(0, 0, tile, 0, tile.Length); { if(GMapProvider.TileImageProxy != null) { ret = GMapProvider.TileImageProxy.FromArray(tile); } } tile = null; } rd.Close(); } } if(!string.IsNullOrEmpty(detachSqlQuery)) { using(DbCommand com = cn.CreateCommand()) { com.CommandText = detachSqlQuery; int x = com.ExecuteNonQuery(); //Debug.WriteLine("Detach: " + x); } } } cn.Close(); } mistachkin added on 2011-12-15 05:59:31 UTC: mistachkin added on 2011-12-15 06:00:03 UTC: anonymous added on 2011-12-16 20:59:34 UTC: mistachkin added on 2011-12-17 01:02:42 UTC: mistachkin added on 2012-01-21 04:39:01 UTC: |