Re: [sqlite] Re: database locked

2006-08-22 Thread Laura Longo



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

2006-08-22 Thread Laura Longo

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] libsqlite3.so

2006-08-22 Thread Laura Longo

"Laura Longo" <[EMAIL PROTECTED]> wrote:


Hi Richard,
I've tried with mkso.sh but an error has immediately stopped me:

make: *** No rule to make target `target_source'.  Stop.



You need to make a copy of Makefile.linux-gcc into your
build directory, change the name to just "Makefile", and
edit the macros at the top to suite your particular
setup.  Or, you can run "configure" at let it build a
Makefile for you.  Either way should work to generate a
Makefile that understands the "target_source" target.




but I don't gave up! I've tried with sqlite-3_3_7-tea.tar.gz as you 
have
suggested... but the result is not very good, already in the 
'configure'...


checking for correct TEA configuration... ok (TEA 3.5)
checking for Tcl configuration... configure: WARNING: Can't find Tcl
configuration definitions




Install Tcl.  http://www.tcl.tk/
Shame on CentOS for not installing it by default!
--
D. Richard Hipp   <[EMAIL PROTECTED]>


Ok, with your help I have installed Tcl and I have built sqlite-3_3_7-tea, 
whith the shared library! Now I can begin to study the source code to try 
solve my problem in this way!


Thank you very much!

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Re: database locked

2006-08-22 Thread Laura Longo


- 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

2006-08-22 Thread Laura Longo


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] libsqlite3.so

2006-08-22 Thread Laura Longo

Hi Clay,
I'm workink under Linux (CentOS), kernel 2.6.16...


That's the right file.

It might be helpful to know what platform you're building on, and if that
platform supports shared libraries.  Shared libraries are usually built by
default on platforms that support them.

As for the source to sqlite3_get_table, it will be visible in your source.
You will probably have to go through the configure process first, because
a lot of the source files aren't built until after the configure process.

Clay Dowling


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] libsqlite3.so

2006-08-22 Thread Laura Longo

Hi all,
I would like to view the source code of libsqlite3.so because of a problem 
with sqlite3_get_table function... I have a question: in the file 
sqlite-3.3.7.tar.gz that I find at http://www.sqlite.org/download.html, are 
there also the source code of the library? If the answer is no, where can I 
find them? Instead, if the answer is yes, what is the option of the 
'configure' command to build the shared library? (I've tried with 
'./configure --enable-shared' but without any result... I only build the 
binary sqlite3)


Laura

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Re: database locked

2006-08-22 Thread Laura Longo

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

2006-08-21 Thread Laura Longo

> 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

2006-08-21 Thread Laura Longo




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

2006-08-21 Thread Laura Longo

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]
-



[sqlite] Re: database locked

2006-08-21 Thread Laura Longo

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]
-



[sqlite] database locked

2006-08-21 Thread Laura Longo
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?

Thanks for your attention

Laura