Hi, my post is quit long so I hope somebody will read to end :)

I've wrote about my problem before but I still cannot find a solution. My 
windows app is using sqlite, it is compiled using VS 2005. I've tried more 
sqlite versions, including 3.6.3. I've tried also to compile sqlite static 
library with optimizations disabled.
There is one process which opens the database and 1-20 worker threads where 
each also opens the database (each has own connection).
Main thread is mostly reading the database and worker threads are reading DB 
and later making writes once per 1-10 seconds. (Begin>delete some 
range>insert>commit) So there is really not heavy load on the database.
Database consists of 2 files, 1st is open and 2nd is attached using ATTACH sql 
- this is used only for reading.

Some customers are reporting crashes caused by random database errors. Some 
examples:

1.sql="begin immediate", code=SQLITE_CANTOPEN msg="unable to open database file"

2. sql="ATTACH ..." code=SQLITE_MISUSE msg="database is locked" (after 20 
retries with sleep(0)). Why SQLITE_MISUSE and not SQLITE_LOCKED ???

3. sql="commit" code=SQLITE_ERROR msg="sql logic error or missing database"

4. sql="delete ..."-after successful BEGIN, code=SQLITE_CANTOPEN msg="unable to 
open database file"

5. sql="select count(*) ..." code=SQLITE_NOMEM 

There were more kind of errors (esp. SQLITE_IOERR_DELETE) but not with latest 
version 3.6.3 AFAIK.

My exec function become quite complex to deal with some error but is not 
sufficient. What can be the problem?
Thank you.

int Exec()
{
...
        while(1)
        {
                rc = _sqlite3_step(m_stmt);

                if (rc == SQLITE_ROW)
                        return 1;

                if (rc == SQLITE_DONE)
                {
                        _sqlite3_reset(m_stmt);
                        return 0;
                }

                if (( rc == SQLITE_BUSY) || (rc == SQLITE_LOCKED))
                {
                        Sleep(0);
                        continue;
                }
        
                if ( (rc & 0xff) == SQLITE_IOERR )
                {
                        if (++errCnt > 20)
                                break;
                        Sleep(100);
                        continue;
                }



                if ( rc == SQLITE_MISUSE )
                {
                        if (++errCnt > 20)
                                break;

                        _sqlite3_reset(m_stmt);
                        Sleep(20);
                        continue;
                }

                break;
        }

        // print error
return -1;
}

_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to