Hi,

I apologize if this is an incorrect forum for this question, but I am
pretty new to SQLite and have been unable to resolve this issue through
other searches. Feel free to direct me to a more appropriate forum.

Essentially, I have written an application in C++ that interfaces (reads
and writes) with a SQLite database, and I am getting lots of 'database is
locked' errors. Right now, I am trying to establish whether those errors
are due to my improper use of SQLite itself, or if the real problem is that
SQLite is not a good fit for my application.

My application runs on Linux (ubuntu 13.10), and is driven by a bash script
that spawns many (~60 on a 64 core workstation) instances of a serial, C++
program, each of which opens its own connection to the database and
performs reads and writes.

*An example SELECT query from my program looks like:*
//open db connection
sqlite3 *db;
char *zErrMsg = 0;
SQLITE3 sql(dbase.c_str());

statement = "SELECT * from configs_table WHERE id='31'";
sql.exe(statement.c_str());
if( sql.vcol_head.size() > 0 ){
   //do things with sql.vdata[]
}//end query returned results

*An example of a write statement looks like:*
statement = "UPDATE configs_table SET searched='2' WHERE id='31'";
sql.exe(statement.c_str());

About 97% of the time, the select statement works fine, but in the other 3%
of cases, I see a 'database is locked' error in the log file of my program.
About 50% of the time, the write statement returns 'database is locked'.

Additionally, if this application is running and I try to query the
database from the terminal, I almost always get a 'database is locked'
error.

Thus, I am wondering if I am doing something wrong in my implementation of
the C++ --> SQLite interaction, or if the real problem is that this
application is not well suited to use with SQLite (I went through the
checklist before implementing it and thought my application passed the
suitability requirements).

Lastly:
A. if it seems like this is an implementation issue, rather than a
capability issue, if I were to scale up my method to spawn say 500-1000
processes at a time (on a supercomputing cluster), would there be any
concern about SQLite scaling to that level?
B. If SQLite is not a good fit for my program, do you have any suggestions
of an alternative database engine that is free or might be free or
inexpensive for academic use?

Thanks in advance,
Kathleen

Reply via email to