Hi,
I have similar problems. We have multiple connections to write to the database 
and the updates are surrounded by create&release savepoints. The issue is when 
two updates from different connections try to modify the database, the second 
operation gonna fail and it either returned database is busy or locked, while 
another operation just keeps occupying the database lock until it finishes. 
After the first operation finishes, the failed operation (a short update) tries 
again with creating a new savepoint but it still fails and after that any 
further operation cannot use the database anymore and all of them fail with 
SQLITE_BUSY or database locked. Is this because we don't create and handle 
savepoints correct? One way to avoid the continuous abort is we use begin 
transaction IMMEDIATE to wrap all our operations but it looks like our solution 
is bandage. I don't know what will be the best solution to solve our issue. If 
anyone could help answer it, I appreciate.
> Date: Mon, 10 Aug 2015 15:40:17 +0300
> From: dm3chip at gmail.com
> To: sqlite-users at mailinglists.sqlite.org
> Subject: [sqlite] Fwd: Problem with SQLite in C++. DB is BUSY (Multithread)
> 
> ---------- Forwarded message ----------
> From: ??????? ??????????? <dm3chip at gmail.com>
> Date: 2015-08-10 0:37 GMT+03:00
> Subject: Problem with SQLite in C++. DB is BUSY (Multithread)
> To: sqlite-users at mailinglists.sqlite.org
> 
> 
> Hello!
> I've got a problem. I'm using sqlite3 in my C++ project. In the log I've
> got error's *DB is locked error code 5*. As I know error code 5 means, that
> DB is busy. To solve this I started to use WAL journal mode. But it doesn't
> help.
> 
> In my program I've got 2 connections to the same db. I use mutexes for both
> DB connections.
> I'm opening connections with this code:
> 
> 
> 
> 
> 
> 
> 
> 
> *if (sqlite3_open_v2(db_path.c_str(), &this->db, SQLITE_OPEN_READWRITE |
> SQLITE_OPEN_CREATE | SQLITE_OPEN_NOMUTEX, 0) ) {
> LOG4CPLUS_FATAL(this->logger, "Can not open/create DB " <<
> sqlite3_errmsg(db));    sqlite3_close(this->db);}if (sqlite3_exec(this->db,
> "PRAGMA journal_mode = WAL;", 0, 0, &err)) {
> LOG4CPLUS_ERROR(this->logger, "SQL det journal mode error: " << err);
> sqlite3_free(err);}*
> 
> First connection is used for inserting data to the DB. It happens with 4
> time every second.
> Second connection is used for starting transaction, selecting, updating,
> deleting data and committing. It happens every 5 seconds.
> 
> I'm getting errors from the first connection.
> 
> Please help me to solve this problem.
> 
> P.S. Sorry for my bad English
> _______________________________________________
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to