I'm periodically seeing sqlite3_exec return SQLITE_CANTOPEN.
Unfortunately, I haven't boiled this down to a simple sample that I can
send to this list, but I thought I'd check to see if there is a known
solution before I dive too deep.  I'm using sqlite version 3.2.7 on
windows.

Thanks!
Pat

The Details
-----------
The sql statement that causes this always seems to be:
"BEGIN IMMEDIATE"

When I inspect my threads in the debugger, there is generally another
transaction closing the database after a "COMMIT", and a third doing
"BEGIN IMMEDIATE" concurrently.  One peculiarity of my system is that I
open and close a new "connection" to the database for each transaction.
I also use a busy_handler that returns 1.  I have debug log statement in
my busy handler and I usually see it called just before this problem
occurs.  

The threads look like this (snipped to sqlite calls):

THREAD A - The thread from which the SQLITE_CANTOPEN is returned.  The
windows GetLastError appears to be "Access is denied" in an attempt to
open the journal file.  I've paused this stack at the line where the
SQLITE_CANTOPEN is returned - line 286 of os_win.c

App.exe!sqlite3OsOpenExclusive(const char * zFilename=0x02425b6a, OsFile
* id=0x02423a58, int delFlag=0)  Line 286
App.exe!pager_open_journal(Pager * pPager=0x024239f8)  Line 2654
App.exe!sqlite3pager_begin(void * pData=0x024276f8, int exFlag=0)  Line
2748 
App.exe!sqlite3BtreeBeginTrans(Btree * pBt=0x02421730, int wrflag=1)
Line 1638 
App.exe!sqlite3VdbeExec(Vdbe * p=0x0240ccb8)  Line 2337
App.exe!sqlite3_step(sqlite3_stmt * pStmt=0x0240ccb8)  Line 217
App.exe!sqlite3_exec(sqlite3 * db=0x02427240, const char *
zSql=0x0268c7e4, int (void *, int, char * *, char * *)*
xCallback=0x00000000, void * pArg=0x00000000, char * *
pzErrMsg=0x0268c468) Line 79
  

THREAD B, also doing a "BEGIN IMMEDIATE"
App.exe!sqlite3OsFileExists(const char * zFilename=0x0241bb72)  Line
148App.exe!hasHotJournal(Pager * pPager=0x02419a00)  Line 2270
App.exe!sqlite3pager_get(Pager * pPager=0x02419a00, unsigned int pgno=1,
void * * ppPage=0x0278b90c)  Line 2336
App.exe!getPage(Btree * pBt=0x0241f7c0, unsigned int pgno=1, MemPage * *
ppPage=0x0278ba10)  Line 1125
App.exe!lockBtree(Btree * pBt=0x0241f7c0)  Line 1445            
App.exe!sqlite3BtreeBeginTrans(Btree * pBt=0x0241f7c0, int wrflag=1)
Line 1634
App.exe!sqlite3VdbeExec(Vdbe * p=0x02422d58)  Line 2337
App.exe!sqlite3_step(sqlite3_stmt * pStmt=0x02422d58)  Line 217
App.exe!sqlite3_exec(sqlite3 * db=0x0241f970, const char *
zSql=0x0278d02c, int (void *, int, char * *, char * *)*
xCallback=0x00000000, void * pArg=0x00000000, char * *
pzErrMsg=0x0278ccb0)  Line 79

THREAD C, calling close after finishing up a transaction:
App.exe!sqlite3OsClose(OsFile * id=0x0240a770)  Line 416
App.exe!sqlite3pager_close(Pager * pPager=0x0240a718)  Line 2011
App.exe!sqlite3BtreeClose(Btree * pBt=0x0243e800)  Line 1299
App.exe!sqlite3_close(sqlite3 * db=0x0240d088)  Line 159

Reply via email to