Re: [sqlite] Sometimes when my process restarts, it returns error "database is locked"

2014-07-25 Thread Mayank Kumar (mayankum)
Hi Simon
I think you mean  this "sqlite3_busy_timeout(db, 2000);"

I am already using this api with busy time of 2sec , but some of my codepaths 
didn't exit the process without closing the db. So I guess I am still going to 
fix that first.
I don't want to increase this more than 2 sec, since there is a single 
connection, if the db is locked its some other problem that needs to be found 
and fix.

Thanks
Mayank


-Original Message-
From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
On Behalf Of Simon Slavin
Sent: Thursday, July 24, 2014 4:09 PM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Sometimes when my process restarts, it returns error 
"database is locked"


On 24 Jul 2014, at 8:21pm, Mayank Kumar (mayankum) <mayan...@cisco.com> wrote:

> Thanks Simon. I found from the code, there are times when our process dies 
> without closing the db , so I will be fixing those.
> 
> Regarding
>> Do you call have a timeout value set before you make the API call which 
>> opens the database ?
> How does this impact the locked db ?

By default, if a process tried to access the database and is locked, SQLite 
immediately returns SQLITE_BUSY or SQLITE_LOCKED and you have to handle the 
problem in your own programming.

If you set a timeout, after finding the database locked, SQLite will wait a 
short while (milliseconds) and then see if the database is unlocked yet.  If 
not, it will was a little longer, then try again.  If still locked it will wait 
a little longer then try again.  It will keep waiting and retrying until the 
timeout period you set has passed.  This is all done inside the SQLite API call 
and you don't have to do any of it inside your own programming.

Many database locking problems are solved by setting a timeout of a couple of 
minutes.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sometimes when my process restarts, it returns error "database is locked"

2014-07-24 Thread Simon Slavin

On 24 Jul 2014, at 8:21pm, Mayank Kumar (mayankum)  wrote:

> Thanks Simon. I found from the code, there are times when our process dies 
> without closing the db , so I will be fixing those.
> 
> Regarding
>> Do you call have a timeout value set before you make the API call which 
>> opens the database ?
> How does this impact the locked db ?

By default, if a process tried to access the database and is locked, SQLite 
immediately returns SQLITE_BUSY or SQLITE_LOCKED and you have to handle the 
problem in your own programming.

If you set a timeout, after finding the database locked, SQLite will wait a 
short while (milliseconds) and then see if the database is unlocked yet.  If 
not, it will was a little longer, then try again.  If still locked it will wait 
a little longer then try again.  It will keep waiting and retrying until the 
timeout period you set has passed.  This is all done inside the SQLite API call 
and you don't have to do any of it inside your own programming.

Many database locking problems are solved by setting a timeout of a couple of 
minutes.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sometimes when my process restarts, it returns error "database is locked"

2014-07-24 Thread Mayank Kumar (mayankum)
Thanks Simon. I found from the code, there are times when our process dies 
without closing the db , so I will be fixing those.

Regarding
> Do you call have a timeout value set before you make the API call which opens 
> the database ?
How does this impact the locked db ?
-mayank

-Original Message-
From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
On Behalf Of Simon Slavin
Sent: Wednesday, July 23, 2014 1:24 PM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Sometimes when my process restarts, it returns error 
"database is locked"


On 23 Jul 2014, at 8:56pm, Mayank Kumar (mayankum) <mayan...@cisco.com> wrote:

> I have already enabled extended error codes but I am not seeing any extended 
> error codes being returned. I also enabled the error logging callback which 
> just prints the errorcode and the error message which I was already getting 
> when the sqlite3 api was failing.

If you have enabled extended error codes you should be getting extended error 
codes returned by the API calls themselves.  I'm afraid that is all you can get.

> I know this error logging callback can report misuse of api's etc, but can 
> this facility or any other logging facility tell me more about why an api is 
> failing like for .e.g. in some customer scenarios I get sqlite_busy or 
> database is locked and I am trying to add the error logging callback to see 
> if I can get more details on why the database is locked or which process has 
> locked it, etc.

Sorry, SQLite does not know what process has the database locked.  The 
processed do not have codes, and no code is stored then the database is locked, 
just the fact that a process wants it to be locked.

> I have only one process which opens a connection to the database and 
> sometimes  when it restarts and then it detects the database is locked 
> although there is no other process which accesses it.

Do you call have a timeout value set before you make the API call which opens 
the database ?

Your description suggests that your process is not unlocking the database 
correctly when it quits to restart.  Is that process quitting under its own 
control, or is it crashing ?  If it is quitting under its own control is should 
be calling sqlite3_close_v2() and then sqlite3_shutdown() and checking the 
responses to make sure it was correctly able to release all resources.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sometimes when my process restarts, it returns error "database is locked"

2014-07-23 Thread Simon Slavin

On 23 Jul 2014, at 8:56pm, Mayank Kumar (mayankum)  wrote:

> I have already enabled extended error codes but I am not seeing any extended 
> error codes being returned. I also enabled the error logging callback which 
> just prints the errorcode and the error message which I was already getting 
> when the sqlite3 api was failing.

If you have enabled extended error codes you should be getting extended error 
codes returned by the API calls themselves.  I'm afraid that is all you can get.

> I know this error logging callback can report misuse of api's etc, but can 
> this facility or any other logging facility tell me more about why an api is 
> failing like for .e.g. in some customer scenarios I get sqlite_busy or 
> database is locked and I am trying to add the error logging callback to see 
> if I can get more details on why the database is locked or which process has 
> locked it, etc.

Sorry, SQLite does not know what process has the database locked.  The 
processed do not have codes, and no code is stored then the database is locked, 
just the fact that a process wants it to be locked.

> I have only one process which opens a connection to the database and 
> sometimes  when it restarts and then it detects the database is locked 
> although there is no other process which accesses it.

Do you call have a timeout value set before you make the API call which opens 
the database ?

Your description suggests that your process is not unlocking the database 
correctly when it quits to restart.  Is that process quitting under its own 
control, or is it crashing ?  If it is quitting under its own control is should 
be calling sqlite3_close_v2() and then sqlite3_shutdown() and checking the 
responses to make sure it was correctly able to release all resources.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sometimes when my process restarts, it returns error "database is locked"

2014-07-23 Thread Mayank Kumar (mayankum)
Thanks Simon, I have already enabled extended error codes but I am not seeing 
any extended error codes being returned. I also enabled the error logging 
callback which just prints the errorcode and the error message which I was 
already getting when the sqlite3 api was failing.  I know this error logging 
callback can report misuse of api's etc, but can this facility or any other 
logging facility tell me more about why an api is failing like for .e.g. in 
some customer scenarios I get sqlite_busy or database is locked and I am trying 
to add the error logging callback to see if I can get more details on why the 
database is locked or which process has locked it, etc. I have only one process 
which opens a connection to the database and sometimes  when it restarts and 
then it detects the database is locked although there is no other process which 
accesses it.


-Mayank





-Original Message-
From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
On Behalf Of Simon Slavin
Sent: Wednesday, July 23, 2014 11:44 AM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Sometimes when my process restarts, it returns error 
"database is locked"


On 23 Jul 2014, at 7:27pm, Mayank Kumar (mayankum) <mayan...@cisco.com> wrote:

> SQLITE_LOG: sqlite errcode=26, sqlite errmsg=file is encrypted or is not a 
> database
> 
> The same error code I get in the return value of sqlite3_step. Just wondering 
> if there is a way  I can get this  error logging call back to  print more 
> details than this ?
> I have enabled extended error codes, is there a way I can get some more error 
> details like :- -what part of the database is corrupted

There is no way to tell.  Sometimes this error is caused by a simple obvious 
part of the file (e.g. the text right at the beginning) but other times it 
means that two parts of the file disagree with each other.  There's no way to 
tell which one got corrupted.  Perhaps they both got corrupted.  Perhaps the 
entire file is corrupt and has been replaced with a text file.

> -what line number or when was this issue first detected

SQLite does not know how your application is organised.  One particular API 
call returns the error, so you know where the error was found: it was by that 
call.

> -what is the extended error code in this scenarios ?

If you have set the flag using

<https://sqlite.org/c3ref/extended_result_codes.html>

then you will get extended error codes.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sometimes when my process restarts, it returns error "database is locked"

2014-07-23 Thread Tim Streater
On 23 Jul 2014 at 19:43, Simon Slavin  wrote: 

>> -what line number or when was this issue first detected
>
> SQLite does not know how your application is organised.  One particular API
> call returns the error, so you know where the error was found: it was by that
> call.

I needed to know which SQLite had an error. So I made a shim around the actual 
PHP calls to SQLite with extra arguments, one of which is a unique code for the 
call. In addition, the shim does all error handling, packaging the error 
message so it can be suitably returned as results of an AJAX request in a way 
that the calling side can readily interpret.



--
Cheers  --  Tim
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sometimes when my process restarts, it returns error "database is locked"

2014-07-23 Thread Simon Slavin

On 23 Jul 2014, at 7:27pm, Mayank Kumar (mayankum)  wrote:

> SQLITE_LOG: sqlite errcode=26, sqlite errmsg=file is encrypted or is not a 
> database
> 
> The same error code I get in the return value of sqlite3_step. Just wondering 
> if there is a way  I can get this  error logging call back to  print more 
> details than this ?
> I have enabled extended error codes, is there a way I can get some more error 
> details like :- -what part of the database is corrupted

There is no way to tell.  Sometimes this error is caused by a simple obvious 
part of the file (e.g. the text right at the beginning) but other times it 
means that two parts of the file disagree with each other.  There's no way to 
tell which one got corrupted.  Perhaps they both got corrupted.  Perhaps the 
entire file is corrupt and has been replaced with a text file.

> -what line number or when was this issue first detected

SQLite does not know how your application is organised.  One particular API 
call returns the error, so you know where the error was found: it was by that 
call.

> -what is the extended error code in this scenarios ?

If you have set the flag using



then you will get extended error codes.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sometimes when my process restarts, it returns error "database is locked"

2014-07-23 Thread Mayank Kumar (mayankum)
[Resending to see if someone has insight here ...]
I was able to get the error logging callback working. But I am curious as I am 
just seeing the same error details as the sqlite3 api itself returns. For e.g.

SQLITE_LOG: sqlite errcode=26, sqlite errmsg=file is encrypted or is not a 
database

The same error code I get in the return value of sqlite3_step. Just wondering 
if there is a way  I can get this  error logging call back to  print more 
details than this ?
I have enabled extended error codes, is there a way I can get some more error 
details like :- -what part of the database is corrupted -what line number or 
when was this issue first detected -what is the extended error code in this 
scenarios ?


-mayank


-Original Message-
From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
On Behalf Of Mayank Kumar (mayankum)
Sent: Friday, July 18, 2014 12:26 PM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Sometimes when my process restarts, it returns error 
"database is locked"

Thanks Simon. Now sqlite3_config is the first call we are making followed by 
sqlite3_open. I am checking the return code for all calls.

In one of the sqlite3_step calls later, I am getting an error "file is 
encrypted or is not a database" but I don't see this callback getting called. 
Immediately after I get this error , the process kills itself purposely.  I am 
only interested in knowing why my callback is not getting called in this 
scenario ?  Is it not getting called because the process is not alive by that 
time or some other issue. The " file is encrypted or is not a database" error 
is being simulated by writing bad data at the  header of the sqlite db while my 
application is running.

Ret =   Sqlite3_step()
Ret = 26
Die()---kills itself

Does the callback gets called before sqlite3_step returns with an error code or 
after ? Since if it gets called after, it may not happen. I want to enable this 
callback to get more fine grained information about  whats going on with out 
system.

Thanks for your help 
Mayank


-Original Message-
From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
On Behalf Of Simon Slavin
Sent: Tuesday, July 15, 2014 11:13 AM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Sometimes when my process restarts, it returns error 
"database is locked"


On 15 Jul 2014, at 6:58pm, Mayank Kumar (mayankum) <mayan...@cisco.com> wrote:

> I was calling it after sqlite3_open,I will try calling before sqlite3_open 
> and update the thread.

When you call sqlite3_config() after sqlite3_open() it returns SQLITE_MISUSE to 
tell you you're doing it wrong.  The fact that you didn't notice this error 
shows us you are not checking the result codes returned by (almost ?) all 
sqlite3 API calls.

Checking these results codes for /every/ call helps programmers spot and 
correct almost all errors.  It's important to check them all because often the 
error is returned by a different call to the one which, logically, should be 
generating the error.  It's simple, you just replace



with something like

if ( != SQLITE_OK) {

}

When people report problems to this list, having them make this change to 
/every/ sqlite3 call makes a lot of them go away.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sometimes when my process restarts, it returns error "database is locked"

2014-07-21 Thread Mayank Kumar (mayankum)
I was able to get the callback working. But I am curious as I am just seeing 
the same error details as the sqlite3 api itself returns. For e.g.

SQLITE_LOG: sqlite errcode=26, sqlite errmsg=file is encrypted or is not a 
database

The same error code I get in the return value of sqlite3_step. Just wondering 
if there is a way  I can get this  error logging call back to  print more 
details than this ?
I have enabled extended error codes, is there a way I can get some more error 
details like :-
-what part of the database is corrupted 
-what line number or when was this issue first detected
-what is the extended error code in this scenarios ?


-mayank


-Original Message-
From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
On Behalf Of Mayank Kumar (mayankum)
Sent: Friday, July 18, 2014 12:26 PM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Sometimes when my process restarts, it returns error 
"database is locked"

Thanks Simon. Now sqlite3_config is the first call we are making followed by 
sqlite3_open. I am checking the return code for all calls.

In one of the sqlite3_step calls later, I am getting an error "file is 
encrypted or is not a database" but I don't see this callback getting called. 
Immediately after I get this error , the process kills itself purposely.  I am 
only interested in knowing why my callback is not getting called in this 
scenario ?  Is it not getting called because the process is not alive by that 
time or some other issue. The " file is encrypted or is not a database" error 
is being simulated by writing bad data at the  header of the sqlite db while my 
application is running.

Ret =   Sqlite3_step()
Ret = 26
Die()---kills itself

Does the callback gets called before sqlite3_step returns with an error code or 
after ? Since if it gets called after, it may not happen. I want to enable this 
callback to get more fine grained information about  whats going on with out 
system.

Thanks for your help 
Mayank


-Original Message-
From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
On Behalf Of Simon Slavin
Sent: Tuesday, July 15, 2014 11:13 AM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Sometimes when my process restarts, it returns error 
"database is locked"


On 15 Jul 2014, at 6:58pm, Mayank Kumar (mayankum) <mayan...@cisco.com> wrote:

> I was calling it after sqlite3_open,I will try calling before sqlite3_open 
> and update the thread.

When you call sqlite3_config() after sqlite3_open() it returns SQLITE_MISUSE to 
tell you you're doing it wrong.  The fact that you didn't notice this error 
shows us you are not checking the result codes returned by (almost ?) all 
sqlite3 API calls.

Checking these results codes for /every/ call helps programmers spot and 
correct almost all errors.  It's important to check them all because often the 
error is returned by a different call to the one which, logically, should be 
generating the error.  It's simple, you just replace



with something like

if ( != SQLITE_OK) {

}

When people report problems to this list, having them make this change to 
/every/ sqlite3 call makes a lot of them go away.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sometimes when my process restarts, it returns error "database is locked"

2014-07-18 Thread Mayank Kumar (mayankum)
Thanks Simon. Now sqlite3_config is the first call we are making followed by 
sqlite3_open. I am checking the return code for all calls.

In one of the sqlite3_step calls later, I am getting an error "file is 
encrypted or is not a database" but I don't see this callback getting called. 
Immediately after I get this error , the process kills itself purposely.  I am 
only interested in knowing why my callback is not getting called in this 
scenario ?  Is it not getting called because the process is not alive by that 
time or some other issue. The " file is encrypted or is not a database" error 
is being simulated by writing bad data at the  header of the sqlite db while my 
application is running.

Ret =   Sqlite3_step()
Ret = 26
Die()---kills itself

Does the callback gets called before sqlite3_step returns with an error code or 
after ? Since if it gets called after, it may not happen. I want to enable this 
callback to get more fine grained information about  whats going on with out 
system.

Thanks for your help 
Mayank


-Original Message-
From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
On Behalf Of Simon Slavin
Sent: Tuesday, July 15, 2014 11:13 AM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Sometimes when my process restarts, it returns error 
"database is locked"


On 15 Jul 2014, at 6:58pm, Mayank Kumar (mayankum) <mayan...@cisco.com> wrote:

> I was calling it after sqlite3_open,I will try calling before sqlite3_open 
> and update the thread.

When you call sqlite3_config() after sqlite3_open() it returns SQLITE_MISUSE to 
tell you you're doing it wrong.  The fact that you didn't notice this error 
shows us you are not checking the result codes returned by (almost ?) all 
sqlite3 API calls.

Checking these results codes for /every/ call helps programmers spot and 
correct almost all errors.  It's important to check them all because often the 
error is returned by a different call to the one which, logically, should be 
generating the error.  It's simple, you just replace



with something like

if ( != SQLITE_OK) {

}

When people report problems to this list, having them make this change to 
/every/ sqlite3 call makes a lot of them go away.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sometimes when my process restarts, it returns error "database is locked"

2014-07-15 Thread Simon Slavin

On 15 Jul 2014, at 6:58pm, Mayank Kumar (mayankum)  wrote:

> I was calling it after sqlite3_open,I will try calling before sqlite3_open 
> and update the thread.

When you call sqlite3_config() after sqlite3_open() it returns SQLITE_MISUSE to 
tell you you're doing it wrong.  The fact that you didn't notice this error 
shows us you are not checking the result codes returned by (almost ?) all 
sqlite3 API calls.

Checking these results codes for /every/ call helps programmers spot and 
correct almost all errors.  It's important to check them all because often the 
error is returned by a different call to the one which, logically, should be 
generating the error.  It's simple, you just replace



with something like

if ( != SQLITE_OK) {

}

When people report problems to this list, having them make this change to 
/every/ sqlite3 call makes a lot of them go away.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sometimes when my process restarts, it returns error "database is locked"

2014-07-15 Thread Mayank Kumar (mayankum)
I was calling it after sqlite3_open,I will try calling before sqlite3_open and 
update the thread.

-Original Message-
From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
On Behalf Of Roger Binns
Sent: Tuesday, July 15, 2014 10:05 AM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Sometimes when my process restarts, it returns error 
"database is locked"

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 14/07/14 22:39, Mayank Kumar (mayankum) wrote:
> The file system is ext3. I am calling this api
> 
> sqlite3_config(SQLITE_CONFIG_LOG, errorLogCallback, NULL);
[...]
> Is my understanding correct since my callback is not getting called ?

Did you check the result of the sqlite3_config call?  It can only be called 
before SQLite is initialised.

You can test that the callback is working by trying to open a database named 
/dev/null and executing any SQL.  This is an example of the diagnostics you 
will get:

  http://rogerbinns.github.io/apsw/tips.html#diagnostics

Roger

-BEGIN PGP SIGNATURE-
Version: GnuPG v1

iEYEARECAAYFAlPFX04ACgkQmOOfHg372QT16gCgoHzHNaGCVAYwxBfu79iXuRt6
B7gAoJY5RX9MCgimDCSeloiXnNrZncgZ
=uqmR
-END PGP SIGNATURE-
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sometimes when my process restarts, it returns error "database is locked"

2014-07-15 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 14/07/14 22:39, Mayank Kumar (mayankum) wrote:
> The file system is ext3. I am calling this api
> 
> sqlite3_config(SQLITE_CONFIG_LOG, errorLogCallback, NULL);
[...]
> Is my understanding correct since my callback is not getting called ?

Did you check the result of the sqlite3_config call?  It can only be
called before SQLite is initialised.

You can test that the callback is working by trying to open a database
named /dev/null and executing any SQL.  This is an example of the
diagnostics you will get:

  http://rogerbinns.github.io/apsw/tips.html#diagnostics

Roger

-BEGIN PGP SIGNATURE-
Version: GnuPG v1

iEYEARECAAYFAlPFX04ACgkQmOOfHg372QT16gCgoHzHNaGCVAYwxBfu79iXuRt6
B7gAoJY5RX9MCgimDCSeloiXnNrZncgZ
=uqmR
-END PGP SIGNATURE-
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sometimes when my process restarts, it returns error "database is locked"

2014-07-14 Thread Mayank Kumar (mayankum)
The file system is ext3. I am calling this api 

sqlite3_config(SQLITE_CONFIG_LOG, errorLogCallback, NULL);

and I expect the errorLogCallback to be called in error conditions to give more 
logs/diagnostics  on what happened. In this callback as suggested I log the 
error code and the message.

When a sqlite3 api like sqlite3_step returns an error like "file is encrypted 
or is not a database" , I expect my callback be also called before the 
sqlite3_Xxx api returns so that I can get more information on what that error 
happened in the first place.

Is my understanding correct since my callback is not getting called ?

-Mayank

-Original Message-
From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
On Behalf Of mm.w
Sent: Friday, July 11, 2014 7:45 PM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Sometimes when my process restarts, it returns error 
"database is locked"

what's your file system? looks like not related at all to sqlite but your code


On Fri, Jul 11, 2014 at 4:31 PM, Mayank Kumar (mayankum) <mayan...@cisco.com
> wrote:

> Hi Richard
> I have enabled error  logging as suggested. Is there a way to test 
> this logging. For e.g. I just corrupted the database by modifying the 
> sqlite db using vi and then got the following message:-
>
> "file is encrypted or is not a database"
> After this error message my process dies(we terminate the process), 
> and I don't see any logs from my callback.  Is this callback called 
> before the sqlite3_xxx calls returns , if yes then why I don't see any 
> error messages from the callback ?
>
> -Mayank
>
>
> -Original Message-
> From: sqlite-users-boun...@sqlite.org [mailto:
> sqlite-users-boun...@sqlite.org] On Behalf Of Richard Hipp
> Sent: Tuesday, July 08, 2014 1:05 PM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] Sometimes when my process restarts, it returns 
> error "database is locked"
>
> On Tue, Jul 8, 2014 at 3:58 PM, Mayank Kumar (mayankum) < 
> mayan...@cisco.com>
> wrote:
>
> > Hi All
> >
> > We have a process with a single sqlite db and a single connection to 
> > the database from a thread. From time to time our processs restarts 
> > and reopens the database or tries to create the database if it 
> > doesn't
> exists.
> >  Sometimes when the process restarts, we get the error "database is
> locked"
> > although the way the process is restarted is the following:-
> >
> > -we always starts the process as a child by doing a vfork and exec 
> > -if we receive a sigchld, we waitpid and finally restarts the 
> > process in same way
> >
>
> I don't think this is possible.  I think something else must be going on.
>
> Have you enabled logging?  See http://www.sqlite.org/errlog.html for 
> details.  The error log might give additional clues.
>
>
>
> >
> > Could this scenario ever lead to database locked scenario, should we 
> > build a retry mechanism when we get this error or this shouldn't 
> > occur if we know the older process has died.
> >
> > Any suggestions?
> >
> > -Mayank
> > ___
> > sqlite-users mailing list
> > sqlite-users@sqlite.org
> > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> >
>
>
>
> --
> D. Richard Hipp
> d...@sqlite.org
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sometimes when my process restarts, it returns error "database is locked"

2014-07-11 Thread mm.w
what's your file system? looks like not related at all to sqlite but your
code


On Fri, Jul 11, 2014 at 4:31 PM, Mayank Kumar (mayankum) <mayan...@cisco.com
> wrote:

> Hi Richard
> I have enabled error  logging as suggested. Is there a way to test this
> logging. For e.g. I just corrupted the database by modifying the sqlite db
> using vi and then got the following message:-
>
> "file is encrypted or is not a database"
> After this error message my process dies(we terminate the process), and I
> don't see any logs from my callback.  Is this callback called before the
> sqlite3_xxx calls returns , if yes then why I don't see any error messages
> from the callback ?
>
> -Mayank
>
>
> -Original Message-
> From: sqlite-users-boun...@sqlite.org [mailto:
> sqlite-users-boun...@sqlite.org] On Behalf Of Richard Hipp
> Sent: Tuesday, July 08, 2014 1:05 PM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] Sometimes when my process restarts, it returns error
> "database is locked"
>
> On Tue, Jul 8, 2014 at 3:58 PM, Mayank Kumar (mayankum) <
> mayan...@cisco.com>
> wrote:
>
> > Hi All
> >
> > We have a process with a single sqlite db and a single connection to
> > the database from a thread. From time to time our processs restarts
> > and reopens the database or tries to create the database if it doesn't
> exists.
> >  Sometimes when the process restarts, we get the error "database is
> locked"
> > although the way the process is restarted is the following:-
> >
> > -we always starts the process as a child by doing a vfork and exec -if
> > we receive a sigchld, we waitpid and finally restarts the process in
> > same way
> >
>
> I don't think this is possible.  I think something else must be going on.
>
> Have you enabled logging?  See http://www.sqlite.org/errlog.html for
> details.  The error log might give additional clues.
>
>
>
> >
> > Could this scenario ever lead to database locked scenario, should we
> > build a retry mechanism when we get this error or this shouldn't occur
> > if we know the older process has died.
> >
> > Any suggestions?
> >
> > -Mayank
> > ___
> > sqlite-users mailing list
> > sqlite-users@sqlite.org
> > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> >
>
>
>
> --
> D. Richard Hipp
> d...@sqlite.org
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sometimes when my process restarts, it returns error "database is locked"

2014-07-11 Thread Mayank Kumar (mayankum)
Hi Richard
I have enabled error  logging as suggested. Is there a way to test this 
logging. For e.g. I just corrupted the database by modifying the sqlite db 
using vi and then got the following message:-

"file is encrypted or is not a database"
After this error message my process dies(we terminate the process), and I don't 
see any logs from my callback.  Is this callback called before the sqlite3_xxx 
calls returns , if yes then why I don't see any error messages from the 
callback ?

-Mayank


-Original Message-
From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
On Behalf Of Richard Hipp
Sent: Tuesday, July 08, 2014 1:05 PM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Sometimes when my process restarts, it returns error 
"database is locked"

On Tue, Jul 8, 2014 at 3:58 PM, Mayank Kumar (mayankum) <mayan...@cisco.com>
wrote:

> Hi All
>
> We have a process with a single sqlite db and a single connection to 
> the database from a thread. From time to time our processs restarts 
> and reopens the database or tries to create the database if it doesn't exists.
>  Sometimes when the process restarts, we get the error "database is locked"
> although the way the process is restarted is the following:-
>
> -we always starts the process as a child by doing a vfork and exec -if 
> we receive a sigchld, we waitpid and finally restarts the process in 
> same way
>

I don't think this is possible.  I think something else must be going on.

Have you enabled logging?  See http://www.sqlite.org/errlog.html for details.  
The error log might give additional clues.



>
> Could this scenario ever lead to database locked scenario, should we 
> build a retry mechanism when we get this error or this shouldn't occur 
> if we know the older process has died.
>
> Any suggestions?
>
> -Mayank
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



--
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sometimes when my process restarts, it returns error "database is locked"

2014-07-08 Thread Simon Slavin

On 8 Jul 2014, at 11:25pm, Mayank Kumar (mayankum)  wrote:

> Our process can restart unexpectedly sometimes and sometimes we die so that 
> we can come up with a new version or failover.

The locking may depend on how the process crashes (restarts) and how much the 
operating system can figure out what happened.  It may or may not release 
locks.  If it does not, then I don't think SQLite can do anything about it 
unless you disable locks or mess with the locking mechanism.

I'm tempted to tell you to figure out what's causing your unexpected restarts, 
so you can fix it.  But of course I don't know your circumstances.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sometimes when my process restarts, it returns error "database is locked"

2014-07-08 Thread Mayank Kumar (mayankum)
Thanks Simon and Richard.

Our process can restart unexpectedly sometimes and sometimes we die so that we 
can come up with a new version or failover. But I am pretty sure we don't do 
anything specifically like closing the db before dieing.  

For cases where we know we are dying, I can put statements to take care of 
closing the db if they are not already there(need to look). But how about the 
case when we unexpectedly get killed and come up again. Is there anything we 
can do to avoid the database locked issue?

-mayank

-Original Message-
From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
On Behalf Of Simon Slavin
Sent: Tuesday, July 08, 2014 2:42 PM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Sometimes when my process restarts, it returns error 
"database is locked"


On 8 Jul 2014, at 8:58pm, Mayank Kumar (mayankum) <mayan...@cisco.com> wrote:

> We have a process with a single sqlite db and a single connection to the 
> database from a thread. From time to time our processs restarts

Does your application close the database as part of the restart process ?

Are you sure that when this happens that there are no unfinalized statements ?

Are you checking the _close() call and reporting an error message if it does 
not return SQLITE_OK ?

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sometimes when my process restarts, it returns error "database is locked"

2014-07-08 Thread Simon Slavin

On 8 Jul 2014, at 8:58pm, Mayank Kumar (mayankum)  wrote:

> We have a process with a single sqlite db and a single connection to the 
> database from a thread. From time to time our processs restarts

Does your application close the database as part of the restart process ?

Are you sure that when this happens that there are no unfinalized statements ?

Are you checking the _close() call and reporting an error message if it does 
not return SQLITE_OK ?

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sometimes when my process restarts, it returns error "database is locked"

2014-07-08 Thread Richard Hipp
On Tue, Jul 8, 2014 at 3:58 PM, Mayank Kumar (mayankum) 
wrote:

> Hi All
>
> We have a process with a single sqlite db and a single connection to the
> database from a thread. From time to time our processs restarts and reopens
> the database or tries to create the database if it doesn't exists.
>  Sometimes when the process restarts, we get the error "database is locked"
> although the way the process is restarted is the following:-
>
> -we always starts the process as a child by doing a vfork and exec
> -if we receive a sigchld, we waitpid and finally restarts the process in
> same way
>

I don't think this is possible.  I think something else must be going on.

Have you enabled logging?  See http://www.sqlite.org/errlog.html for
details.  The error log might give additional clues.



>
> Could this scenario ever lead to database locked scenario, should we build
> a retry mechanism when we get this error or this shouldn't occur if we know
> the older process has died.
>
> Any suggestions?
>
> -Mayank
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Sometimes when my process restarts, it returns error "database is locked"

2014-07-08 Thread Mayank Kumar (mayankum)
Hi All

We have a process with a single sqlite db and a single connection to the 
database from a thread. From time to time our processs restarts and reopens the 
database or tries to create the database if it doesn't exists.  Sometimes when 
the process restarts, we get the error "database is locked" although the way 
the process is restarted is the following:-

-we always starts the process as a child by doing a vfork and exec
-if we receive a sigchld, we waitpid and finally restarts the process in same 
way

Could this scenario ever lead to database locked scenario, should we build a 
retry mechanism when we get this error or this shouldn't occur if we know the 
older process has died.

Any suggestions?

-Mayank
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users