[sqlite] Fwd: Problem with SQLite in C++. DB is BUSY (Multithread)

2015-08-12 Thread ch
We tried already, still fail without correct recovery. 

> From: slavins at bigfraud.org
> Date: Tue, 11 Aug 2015 03:43:59 +0100
> To: sqlite-users at mailinglists.sqlite.org
> Subject: Re: [sqlite] Fwd: Problem with SQLite in C++. DB is BUSY 
> (Multithread)
> 
> 
> On 11 Aug 2015, at 2:28am, ch  wrote:
> 
> > Is this because we don't create and handle savepoints correct?
> 
> Have you set a timeout value using the routine I pointed to earlier ?  If 
> not, do so.
> 
> Simon.
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



[sqlite] Fwd: Problem with SQLite in C++. DB is BUSY (Multithread)

2015-08-11 Thread Teg
Hello ch,

I'd say yes it'll block. As to whether this is a problem I guess it
depends on how much writing you do. I break my writing down into
sections so, there's time in between transactions for readers to get
in and read.

WAL mode should work. It used to work for me a number of versions back.

If I was going to look deeper into this I'd use a fresh simple table
put the new DB into WAL mode and experiment with 2-3 processes trying
to access the fresh DB.

Tuesday, August 11, 2015, 8:08:39 PM, you wrote:

c> We didn't try journal mode but the WAL mode doesn't work for us
c> even if we set busy timeout handler to try to go across this.
c> Unfortunately, the busy timeout handler doesn't get called every
c> time and after that we still cannot get the file recovered
c> correctly. The issue is still shown in 3.8.8.3. Thanks for letting
c> me know journal mode working for you! However, is reading gonna
c> blocked by writing in journal mode? I thought that is the sqlite documents 
mentioned.

>> Date: Tue, 11 Aug 2015 00:41:50 -0400
>> From: Teg at djii.com
>> To: chaihua_sina at hotmail.com
>> CC: sqlite-users at mailinglists.sqlite.org
>> Subject: Re: [sqlite] Fwd: Problem with SQLite in C++. DB is BUSY 
>> (Multithread)
>> 
>> Hello ch,
>> 
>> I  ran  into  a  similar  problem when I was trying to use WAL mode. I
>> ended up just turning it off. It seemed that once there was contention
>> for  the  file  it never recovered. This was in windows. I didn't look
>> into  it  any  deeper  than this.  The same code works fine in journal
>> mode.  I  haven't  tried  it  again with the latest.I think I last
>> tested this in 3.8.8.2.
>> 
>> There's  typically  not  much more than 2-3 connections contending for
>> file  access  in my program. Most of the time it's only one connection
>> at a time.
>> 
>> I  assumed  it  was something I was doing because I wasn't reading any
>> other reports of it. 
>> 
>> C
>> 
>> 
>> Monday, August 10, 2015, 9:28:03 PM, you wrote:
>> 
>> c> Hi,
>> c> I have similar problems. We have multiple connections to write to
>> c> the database and the updates are surrounded by create
>> c> savepoints. The issue is when two updates from different
>> c> connections try to modify the database, the second operation gonna
>> c> fail and it either returned database is busy or locked, while
>> c> another operation just keeps occupying the database lock until it
>> c> finishes. After the first operation finishes, the failed operation
>> c> (a short update) tries again with creating a new savepoint but it
>> c> still fails and after that any further operation cannot use the
>> c> database anymore and all of them fail with SQLITE_BUSY or database
>> c> locked. Is this because we don't create and handle savepoints
>> c> correct? One way to avoid the continuous abort is we use begin
>> c> transaction IMMEDIATE to wrap all our operations but it looks like
>> c> our solution is bandage. I don't know what will be the best
>> c> 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: ??? ??? 
>> >> 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(), >db, SQLITE_OPEN_READWRITE |
>> >> SQLITE_OPEN_CREATE | SQLITE_OPEN_NOMUTEX, 0) ) {
>> >> LOG4CPLUS_FATAL(this->logger, "Ca

[sqlite] Fwd: Problem with SQLite in C++. DB is BUSY (Multithread)

2015-08-11 Thread ch
Hi,
I have similar problems. We have multiple connections to write to the database 
and the updates are surrounded by create 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: ??? ??? 
> 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(), >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, )) {
> 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



[sqlite] Fwd: Problem with SQLite in C++. DB is BUSY (Multithread)

2015-08-11 Thread Simon Slavin

On 11 Aug 2015, at 2:28am, ch  wrote:

> Is this because we don't create and handle savepoints correct?

Have you set a timeout value using the routine I pointed to earlier ?  If not, 
do so.

Simon.


[sqlite] Fwd: Problem with SQLite in C++. DB is BUSY (Multithread)

2015-08-11 Thread Teg
Hello ch,

I  ran  into  a  similar  problem when I was trying to use WAL mode. I
ended up just turning it off. It seemed that once there was contention
for  the  file  it never recovered. This was in windows. I didn't look
into  it  any  deeper  than this.  The same code works fine in journal
mode.  I  haven't  tried  it  again with the latest.I think I last
tested this in 3.8.8.2.

There's  typically  not  much more than 2-3 connections contending for
file  access  in my program. Most of the time it's only one connection
at a time.

I  assumed  it  was something I was doing because I wasn't reading any
other reports of it. 

C


Monday, August 10, 2015, 9:28:03 PM, you wrote:

c> Hi,
c> I have similar problems. We have multiple connections to write to
c> the database and the updates are surrounded by create
c> savepoints. The issue is when two updates from different
c> connections try to modify the database, the second operation gonna
c> fail and it either returned database is busy or locked, while
c> another operation just keeps occupying the database lock until it
c> finishes. After the first operation finishes, the failed operation
c> (a short update) tries again with creating a new savepoint but it
c> still fails and after that any further operation cannot use the
c> database anymore and all of them fail with SQLITE_BUSY or database
c> locked. Is this because we don't create and handle savepoints
c> correct? One way to avoid the continuous abort is we use begin
c> transaction IMMEDIATE to wrap all our operations but it looks like
c> our solution is bandage. I don't know what will be the best
c> 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: ??? ??? 
>> 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(), >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, )) {
>> 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
c>   
c> ___
c> sqlite-users mailing list
c> sqlite-users at mailinglists.sqlite.org
c> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



-- 
 Tegmailto:Teg at djii.com



[sqlite] Fwd: Problem with SQLite in C++. DB is BUSY (Multithread)

2015-08-10 Thread Дмитрий Чепуровский
-- Forwarded message --
From: ??? ??? 
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(), >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, )) {
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