Re: [sqlite] Re: database locked
Do you have the 'fuser' command in your flavor of linux/unix? http://linux.about.com/library/cmd/blcmdl1_fuser.htm Yes! Could this help? Sorry for this stupid question, I've read the man pages... it's a wonderful command! Thank you Jay! Laura - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Re: database locked
On 8/22/06, Laura Longo <[EMAIL PROTECTED]> wrote: > Do you have the 'fuser' command in your flavor of linux/unix? > > http://linux.about.com/library/cmd/blcmdl1_fuser.htm > Yes! Could this help? If some other program has the file open it will tell you. When you get a lockup use it to figure out who is locking the file. - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Re: database locked
Do you have the 'fuser' command in your flavor of linux/unix? http://linux.about.com/library/cmd/blcmdl1_fuser.htm Yes! Could this help? - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Re: database locked
In the source code at the begin of the two processes that execute queries on the database I've used the code: srand(time(NULL)); to avoid collisions... (I never started the two processes at the same instant) That should work great. >> >> http://www.sqlite.org/capi3ref.html#sqlite3_busy_timeout >> >> If this does not fix your problem, it is possible that an application has >> a read lock permanently open. Check that your readers are not doing a >> begin without a commit. > > That was my thought too. It sounds like something else has the file > locked. > > Laura is there a backup program that might be reading your database > and locking it? Only my two processes execute queries on the database and no other program... Is there any other way to be sure of this? Can you suggest me a test to do when the lock will happen again to have more info? Do you have the 'fuser' command in your flavor of linux/unix? http://linux.about.com/library/cmd/blcmdl1_fuser.htm - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Re: database locked
- Original Message - From: "Jay Sprenkle" <[EMAIL PROTECTED]> To: <sqlite-users@sqlite.org> Sent: Tuesday, August 22, 2006 6:06 PM Subject: Re: [sqlite] Re: database locked On 8/22/06, Christian Smith <[EMAIL PROTECTED]> wrote: Laura Longo uttered: > > >> On 8/21/06, Laura Longo <[EMAIL PROTECTED]> wrote: >>> I've tried also executing the query "begine exclusive" before the >>> "update", >>> and "commit" to end the entire routine, and the query that now >>> returns the >>> exit code 5 (database locked) is "begin exclusive", I don't know if >>> this >>> can be meaningful... >> >> It sounds like some other application has locked the database file. >> Do you have a virus scanner? This can sometimes cause problems. >> It will lock the file you use for the database. > > My applications are running under Linux (CentOS, kernel 2.6.16) and I > have no > virus scanner. Try using sqlite3_busy_timeout(), to get round the temporary locks if possible. SQLite will retry locked database access until the command either succeeds or times out. She already has a nice variable delay retry in her code. As long as she seeds the random number generator with a different seed for each process It should eliminate problems with synchronized retry collisions. In the source code at the begin of the two processes that execute queries on the database I've used the code: srand(time(NULL)); to avoid collisions... (I never started the two processes at the same instant) http://www.sqlite.org/capi3ref.html#sqlite3_busy_timeout If this does not fix your problem, it is possible that an application has a read lock permanently open. Check that your readers are not doing a begin without a commit. That was my thought too. It sounds like something else has the file locked. Laura is there a backup program that might be reading your database and locking it? Only my two processes execute queries on the database and no other program... Is there any other way to be sure of this? Can you suggest me a test to do when the lock will happen again to have more info? Laura - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Re: database locked
On Tue, 22 Aug 2006, Laura Longo wrote: > Date: Tue, 22 Aug 2006 08:51:34 +0200 > From: Laura Longo <[EMAIL PROTECTED]> > Reply-To: sqlite-users@sqlite.org > To: sqlite-users@sqlite.org > Subject: Re: [sqlite] Re: database locked > > > Laura, > > > > 'df -h' should give you some hints, or 'showmount'. I run on BSD not > > Linux, > > but most unix like OS's will tell you if the mount point is a hard drive > > or a remote mount, in which case, it will have a hostname:/path instead of > > a /dev/dsk device file as the device/partition information. > > > > HTH. > > Rob. > > > > Hi Rob, > sorry for the delay, the result of df -h is this: > > FilesystemSize Used Avail Use% Mounted on > /dev/sda1 3.9G 1.6G 2.2G 42% / > none 504M 0 504M 0% /dev/shm > /dev/sda4 9.7G 2.5G 6.7G 27% /home > /dev/sda3 136G 32G 97G 25% /var > > Then, if I've understood well, my filesystem is not residing on an NFS > mounted disk... That looks to be true. The NFS mount would look different than the /dev/sda? mounts. Sorry, your problem is something else. Cheers, Rob. - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Re: database locked
On 8/22/06, Christian Smith <[EMAIL PROTECTED]> wrote: Laura Longo uttered: > > >> On 8/21/06, Laura Longo <[EMAIL PROTECTED]> wrote: >>> I've tried also executing the query "begine exclusive" before the >>> "update", >>> and "commit" to end the entire routine, and the query that now returns the >>> exit code 5 (database locked) is "begin exclusive", I don't know if this >>> can be meaningful... >> >> It sounds like some other application has locked the database file. >> Do you have a virus scanner? This can sometimes cause problems. >> It will lock the file you use for the database. > > My applications are running under Linux (CentOS, kernel 2.6.16) and I have no > virus scanner. Try using sqlite3_busy_timeout(), to get round the temporary locks if possible. SQLite will retry locked database access until the command either succeeds or times out. She already has a nice variable delay retry in her code. As long as she seeds the random number generator with a different seed for each process It should eliminate problems with synchronized retry collisions. http://www.sqlite.org/capi3ref.html#sqlite3_busy_timeout If this does not fix your problem, it is possible that an application has a read lock permanently open. Check that your readers are not doing a begin without a commit. That was my thought too. It sounds like something else has the file locked. Laura is there a backup program that might be reading your database and locking it? - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Re: database locked
Try using sqlite3_busy_timeout(), to get round the temporary locks if possible. SQLite will retry locked database access until the command either succeeds or times out. http://www.sqlite.org/capi3ref.html#sqlite3_busy_timeout If this does not fix your problem, it is possible that an application has a read lock permanently open. Check that your readers are not doing a begin without a commit. Christian Hi Christian, the strange thing is that two processes are doing query on the same sqlite3 database, but if the two processes begin to fail the queries 'update' and I restart only one of them, the process that I have restarted executes the queries 'update' in the correct way for some days, while the other continues to fail... Now I'm tryng to get more info about the library libsqlite3.so... I don't know what to think... I've checked for 'begin' without 'commit', but my processes are in a loop of 10 seconds and they go on for some days before having problems, the queries are about the same, with small differeces... Laura - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Re: database locked
Laura Longo uttered: On 8/21/06, Laura Longo <[EMAIL PROTECTED]> wrote: I've tried also executing the query "begine exclusive" before the "update", and "commit" to end the entire routine, and the query that now returns the exit code 5 (database locked) is "begin exclusive", I don't know if this can be meaningful... It sounds like some other application has locked the database file. Do you have a virus scanner? This can sometimes cause problems. It will lock the file you use for the database. My applications are running under Linux (CentOS, kernel 2.6.16) and I have no virus scanner. Try using sqlite3_busy_timeout(), to get round the temporary locks if possible. SQLite will retry locked database access until the command either succeeds or times out. http://www.sqlite.org/capi3ref.html#sqlite3_busy_timeout If this does not fix your problem, it is possible that an application has a read lock permanently open. Check that your readers are not doing a begin without a commit. Christian -- /"\ \ /ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL X - AGAINST MS ATTACHMENTS / \ - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Re: database locked
Laura, 'df -h' should give you some hints, or 'showmount'. I run on BSD not Linux, but most unix like OS's will tell you if the mount point is a hard drive or a remote mount, in which case, it will have a hostname:/path instead of a /dev/dsk device file as the device/partition information. HTH. Rob. Hi Rob, sorry for the delay, the result of df -h is this: FilesystemSize Used Avail Use% Mounted on /dev/sda1 3.9G 1.6G 2.2G 42% / none 504M 0 504M 0% /dev/shm /dev/sda4 9.7G 2.5G 6.7G 27% /home /dev/sda3 136G 32G 97G 25% /var Then, if I've understood well, my filesystem is not residing on an NFS mounted disk... - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Re: database locked
> On 8/21/06, Laura Longo <[EMAIL PROTECTED]> wrote: >> I've tried also executing the query "begine exclusive" before the >> "update", >> and "commit" to end the entire routine, and the query that now returns >> the >> exit code 5 (database locked) is "begin exclusive", I don't know if >> this >> can be meaningful... > > It sounds like some other application has locked the database file. > Do you have a virus scanner? This can sometimes cause problems. > It will lock the file you use for the database. My applications are running under Linux (CentOS, kernel 2.6.16) and I have no virus scanner. The database is not residing on an NFS mounted disk by any chance? I'm not very expert... I don't think, how can I verify this under Linux? - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Re: database locked
On Mon, 21 Aug 2006, Laura Longo wrote: > Date: Mon, 21 Aug 2006 20:01:24 +0200 > From: Laura Longo <[EMAIL PROTECTED]> > Reply-To: sqlite-users@sqlite.org > To: sqlite-users@sqlite.org > Subject: Re: [sqlite] Re: database locked > > > > > On 8/21/06, Laura Longo <[EMAIL PROTECTED]> wrote: > >> I've tried also executing the query "begine exclusive" before the > >> "update", > >> and "commit" to end the entire routine, and the query that now returns > >> the > >> exit code 5 (database locked) is "begin exclusive", I don't know if this > >> can be meaningful... > > > > It sounds like some other application has locked the database file. > > Do you have a virus scanner? This can sometimes cause problems. > > It will lock the file you use for the database. > > My applications are running under Linux (CentOS, kernel 2.6.16) and I have > no > virus scanner. The database is not residing on an NFS mounted disk by any chance? - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Re: database locked
On 8/21/06, Laura Longo <[EMAIL PROTECTED]> wrote: I've tried also executing the query "begine exclusive" before the "update", and "commit" to end the entire routine, and the query that now returns the exit code 5 (database locked) is "begin exclusive", I don't know if this can be meaningful... It sounds like some other application has locked the database file. Do you have a virus scanner? This can sometimes cause problems. It will lock the file you use for the database. My applications are running under Linux (CentOS, kernel 2.6.16) and I have no virus scanner. - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Re: database locked
On 8/21/06, Laura Longo <[EMAIL PROTECTED]> wrote: I've tried also executing the query "begine exclusive" before the "update", and "commit" to end the entire routine, and the query that now returns the exit code 5 (database locked) is "begin exclusive", I don't know if this can be meaningful... It sounds like some other application has locked the database file. Do you have a virus scanner? This can sometimes cause problems. It will lock the file you use for the database. - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Re: database locked
This looks like it should work fine. The only thing that concerns me is this could be a very long loop if something locks the table or there's an error that's not recoverable. It would sit there forever retrying something that will never be fixed. Some operations will cause the database to be reorganized and will return schema errors when you run a prepared statement. You have to re prepare your statement to get it to work. I'm not sure if that applies to get_table though. I've tried also executing the query "begine exclusive" before the "update", and "commit" to end the entire routine, and the query that now returns the exit code 5 (database locked) is "begin exclusive", I don't know if this can be meaningful... I see the calls to free the memory if it fails. Do you free the memory used after success too? Yes. You might look through the source code for sqlite3_get_table(). You could put some debugging output there to help figure out what's going wrong. Ok, I try with the source code of the library! Thank you very much for your help. Laura - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Re: database locked
On 8/21/06, Laura Longo <[EMAIL PROTECTED]> wrote: 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. This looks like it should work fine. The only thing that concerns me is this could be a very long loop if something locks the table or there's an error that's not recoverable. It would sit there forever retrying something that will never be fixed. Some operations will cause the database to be reorganized and will return schema errors when you run a prepared statement. You have to re prepare your statement to get it to work. I'm not sure if that applies to get_table though. I see the calls to free the memory if it fails. Do you free the memory used after success too? You might look through the source code for sqlite3_get_table(). You could put some debugging output there to help figure out what's going wrong. -- SqliteImporter and SqliteReplicator: Command line utilities for Sqlite http://www.reddawn.net/~jsprenkl/Sqlite Cthulhu Bucks! http://www.cthulhubucks.com - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] Re: database locked
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(), , , , ); 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(), , , ,); } ... where os is a pointer to an open file. - To unsubscribe, send email to [EMAIL PROTECTED] -