On 8/21/06, Laura Longo <[EMAIL PROTECTED]> wrote:
Hi all,
I'm a software developer and I'm using sqlite3 for my application in c++. This is the problem I've found: two processes do queries (about 1 query per second) on one database; the 'select' queries don't have any problem, while 'update' queries find problems after 1 or 2 days that the processes are running. In fact, generally the 'update' queries begin to fail with the exit code 5 (database locked) with sqlite3_get_table(), while the 'select' queries are ok. If I stop and restart one of the two processes, this process does for some days all the queries in the right way and then begins again to give problems, while the other continues to return 'database locked' error. I don't understand the problem... Am I doing something wrong? Can anyone help me?

Are you checking for database locked return codes and retrying the
operation (on updates)?

Yes, I use a wrapper around the function sqlite3_get_table which, if the return code if different from 0, retries to execute the query calling again sqlite3_get_table doing a 'while'. Besides, each query is written in a file for debugging purpose (in this way I've seen the problem). Here is the code that I use.
...
rc = sqlite3_get_table(db, query.c_str(), &result, &nrow, &ncolumn, &errmsg);
while(rc != 0)
{
   sqlite3_free_table(result);
   if(errmsg != NULL)
      os << "error: " << rc << " " << string(errmsg) << endl;
   else
      os << "generic error\n";
   sqlite3_free(errmsg);
   os << query << endl;
   int b = (int) ((rand()/(float) RAND_MAX) * 1000);
   Sleep(b);
rc = sqlite3_get_table(db, query.c_str(), &result, &nrow, &ncolumn,&errmsg);
}
...

where os is a pointer to an open file.
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to