Hello all,

Sorry for the delay.  It’s really hard to get this error to happen but I have 
some more relevant information.

I observed a read only connection (there are two connections open to the DB, 
one for reading only and one for writing / internal reading) suddenly start 
returning error code 26, and then error code 11 for a query so I pulled the 
database file.  It’s encrypted with SQLCipher, but I opened it with the 
sqlcipher command line and ran PRAGMA quick_check.  Normally when a corruption 
occurs this will show me what happened, but in this case it returned “ok.”  
However, the query results never ended.  I killed the process when it passed 2 
GB of output from a 6 MB database from a SELECT query.  This seems like 
corruption that the PRAGMA missed.  SELECT

One thing to note that I found was at one point during the testing today I 
found that sqlite3_prepare_v2 crashed while attempting to access invalid 
memory.  This led me to research prepared statements and find that operations 
on them are not actually thread safe.  So I will be changing the write 
connection mode to serialized and testing further but I wanted to report on the 
odd behavior I found above.  

I’m having trouble getting any output from the sqlite error log since this is a 
C# application.  I have written a P Invoke binding to the method but I’m unsure 
if it is succeeding or not.  How often should I expect output from it?  Is 
there a way I can force it to output something to test it?

As for the second suggestion, I am able to open the database with the sqlcipher 
command line so I assume that the database header is intact.  There were two 
instances of reported corruption today (perhaps three if I interpret the 
invalid memory access as the same problem showing a different result).  One 
showed “bTreeInitPage() returned error code 11” for some page in the 5000 range 
(this is usually the error I get, with various pages being listed as the bad 
ones between runs) and the other showed “ok” but had the never ending SELECT 
output on certain queries.

Please let me know if anything comes to mind.  

Jim Borden
Software Engineer

jim.bor...@couchbase.com

On 6/24/16, 4:25 AM, "sqlite-users-boun...@mailinglists.sqlite.org on behalf of 
Richard Hipp" <sqlite-users-boun...@mailinglists.sqlite.org on behalf of 
d...@sqlite.org> wrote:

>On Thu, Jun 23, 2016 at 6:13 PM, Jim Borden <jim.bor...@couchbase.com> wrote:
>> The library will be happily running along and then suddenly a SELECT 
>> statement will return error code 26 upon step.
>
>Error code 26 is SQLITE_NOTADB.  That only happens when SQLite is
>reading the 100-byte header at the beginning of the database file and
>finds that header is correct.  This is given a discinct error code
>because usually that finding means that you are trying to open
>something that is not really an SQLite database file.
>
>Debugging hints:
>
>(1) Set error logging on your application:  https://www.sqlite.org/errlog.html
>
>(2) Compile the "showdb" utility program (using "make showdb") and
>then run "showdb DATABASE dbheader" on a corrupt database file.  Send
>the results to this list.  (There are many other useful run-time
>options for "showdb" that you might also find useful.)
>
>
>>
>>
>> This connection is in “multi thread” mode I think (compiled with thread 
>> safety on but opened with NO_MUTEX).
>
>Does the problem go away if you se the threading mode to "serialized"?
>
>-- 
>D. Richard Hipp
>d...@sqlite.org
>_______________________________________________
>sqlite-users mailing list
>sqlite-users@mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to