Re: [sqlite] Database locking Error

2013-08-30 Thread Simon Slavin

On 30 Aug 2013, at 5:36am, techi eth  wrote:

> Thanks for suggestion. I will take it forward.
> 
> locking will happen with two simultaneous processes accessing for read also?

I don't think it can happen if they're both reading.  But a process which is 
reading could block a process which is writing, and a process which is writing 
could block a process which is reading.

The easiest way to cope with it is to always set a timeout and handle the error 
correctly.

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


Re: [sqlite] Database locking Error

2013-08-29 Thread techi eth
Thanks for suggestion. I will take it forward.

locking will happen with two simultaneous processes accessing for read also?

Thanks


On 8/29/13, Simon Slavin  wrote:
>
> On 29 Aug 2013, at 6:48am, techi eth  wrote:
>
>> I am checking for all the function.As of now i am not using sqlite3 time
>> out but testing application will take decision accordingly to recall the
>> operation based on type of error.
>
> If you have two simultaneous processes accessing the same database and have
> not set a timeout, that explains your locking errors.  You will get constant
> collisions as both processes try to access the database at the same time and
> if you haven't set a timeout every one of these will instantly be reported
> as a locking error.
>
> I suggest you set a timeout in both processes to, perhaps, 5 seconds.  This
> means that the processes will each retry for anything up to 5 seconds before
> reporting locking errors.
>
> 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] Database locking Error

2013-08-29 Thread Simon Slavin

On 29 Aug 2013, at 6:48am, techi eth  wrote:

> I am checking for all the function.As of now i am not using sqlite3 time
> out but testing application will take decision accordingly to recall the
> operation based on type of error.

If you have two simultaneous processes accessing the same database and have not 
set a timeout, that explains your locking errors.  You will get constant 
collisions as both processes try to access the database at the same time and if 
you haven't set a timeout every one of these will instantly be reported as a 
locking error.

I suggest you set a timeout in both processes to, perhaps, 5 seconds.  This 
means that the processes will each retry for anything up to 5 seconds before 
reporting locking errors.

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


Re: [sqlite] Database locking Error

2013-08-28 Thread techi eth
I am checking for all the function.As of now i am not using sqlite3 time
out but testing application will take decision accordingly to recall the
operation based on type of error.



On Wed, Aug 28, 2013 at 3:03 PM, Simon Slavin  wrote:

>
> On 28 Aug 2013, at 9:24am, techi eth  wrote:
>
> > Yes, i am checking the return code.
>
> Just for the function that gives the error, or for the calls before that
> too ?
>
> And are you setting a timeout ?  If so, for how long ?
>
> 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] Database locking Error

2013-08-28 Thread Simon Slavin

On 28 Aug 2013, at 9:24am, techi eth  wrote:

> Yes, i am checking the return code.

Just for the function that gives the error, or for the calls before that too ?

And are you setting a timeout ?  If so, for how long ?

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


Re: [sqlite] Database locking Error

2013-08-28 Thread techi eth
Yes, i am checking the return code.


On Tue, Aug 27, 2013 at 5:09 PM, Simon Slavin  wrote:

>
> On 27 Aug 2013, at 5:15am, techi eth  wrote:
>
> > For read operation i am doing _prepare(), _step(), _finalize().
> > For all other operation i am doing _exec().
> >
> > Do you see any issue ?
>
> Nothing obvious from what I already know apart from the fact that you
> don't mention setting a timeout:
>
> 
> 
>
> Without that, a process getting a lock won't back off and retry, it'll
> just immediately return an error.  Which is almost never what people want.
>  You would probably be better off setting this to 5 seconds or something.
>
> I suspect that the process which is getting the lock is fine and that it's
> the other process which is keeping the file locked.
>
> Are you checking the return codes from /all/ your SQLite calls in other
> processes ?  The code you included doesn't seem to do that but I thought
> that might be pseudocode.
>
> 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] Database locking Error

2013-08-27 Thread Simon Slavin

On 27 Aug 2013, at 5:15am, techi eth  wrote:

> For read operation i am doing _prepare(), _step(), _finalize().
> For all other operation i am doing _exec().
> 
> Do you see any issue ?

Nothing obvious from what I already know apart from the fact that you don't 
mention setting a timeout:




Without that, a process getting a lock won't back off and retry, it'll just 
immediately return an error.  Which is almost never what people want.  You 
would probably be better off setting this to 5 seconds or something.

I suspect that the process which is getting the lock is fine and that it's the 
other process which is keeping the file locked.

Are you checking the return codes from /all/ your SQLite calls in other 
processes ?  The code you included doesn't seem to do that but I thought that 
might be pseudocode.

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


Re: [sqlite] Database locking Error

2013-08-26 Thread techi eth
For read operation i am doing _prepare(), _step(), _finalize().
For all other operation i am doing _exec().

Do you see any issue ?

Cheers -
Techi


On Mon, Aug 26, 2013 at 9:22 PM, Simon Slavin  wrote:

>
> On 26 Aug 2013, at 9:02am, techi eth  wrote:
>
> > Fun_Read() on TblTest**
> > /* Do the periodic read operation by using db handler return from above*/
>
> How is your read done ?  Do you use _exec() like you do for the PRAGMA, or
> _prepare(), _step(), _finalize(), or _query() or something else ?
>
> 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] Database locking Error

2013-08-26 Thread Simon Slavin

On 26 Aug 2013, at 9:02am, techi eth  wrote:

> Fun_Read() on TblTest**
> /* Do the periodic read operation by using db handler return from above*/

How is your read done ?  Do you use _exec() like you do for the PRAGMA, or 
_prepare(), _step(), _finalize(), or _query() or something else ?

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


Re: [sqlite] Database locking Error

2013-08-26 Thread Keith Medcalf
> >You only have to do this once, e.g. at database creation.
> >Journal mode WAL is a persistent property of the database file.
> >Every connection will respect it.
 
> All PRAGMA Option is attached to database as a persistent property?

No, only the ones which are persistent.  Journal_mode is persistent.
 
> Is their any issue if we set all option again with every new connection
> to same file?

No.  You can set them every time if you wish without harm.  In fact if you are 
using a shared sqlite3 engine that you did not compile this may be a good idea 
as otherwise you have no way to know what defaults/settings are in place (other 
than prayer).





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


Re: [sqlite] Database locking Error

2013-08-26 Thread techi eth
Oppps. Apologies for my mistake.

My test is working correctly now.

Thanks a lot.

>You only have to do this once, e.g. at database creation.
>Journal mode WAL is a persistent property of the database file.
>Every connection will respect it.

All PRAGMA Option is attached to database as a persistent property?

Is their any issue if we set all option again with every new connection to
same file?


On Mon, Aug 26, 2013 at 2:40 PM, Kees Nuyt  wrote:

> On Mon, 26 Aug 2013 13:32:42 +0530, techi eth 
> wrote:
>
> >PRAGMA jouranl_mode = WAL
>
> That's misspelled, both in your text and in your code.
>
> Try:
> PRAGMA journal_mode=WAL;
>
> You only have to do this once, e.g. at database creation.
> Journal mode WAL is a persistent property of the database file.
> Every connection will respect it.
>
> --
> Groet, Cordialement, Pozdrawiam, Regards,
>
> Kees Nuyt
>
> ___
> 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] Database locking Error

2013-08-26 Thread Kees Nuyt
On Mon, 26 Aug 2013 13:32:42 +0530, techi eth 
wrote:

>PRAGMA jouranl_mode = WAL

That's misspelled, both in your text and in your code.

Try:
PRAGMA journal_mode=WAL;

You only have to do this once, e.g. at database creation. 
Journal mode WAL is a persistent property of the database file.
Every connection will respect it.

-- 
Groet, Cordialement, Pozdrawiam, Regards,

Kees Nuyt

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


Re: [sqlite] Database locking Error

2013-08-26 Thread techi eth
Thanks.

I tried using PRAGMA jouranl_mode = WAL but still it is getting failed for
some time. Find below  more details.

Process 1:

Fun_Open()

sqlite3_open(DATABASE, );

sqlite3_exec(dbUpdate, " PRAGMA jouranl_mode = WAL", NULL, NULL, );

Fun_Update() on TblTest

/* Do the periodic update operation by using db handler return from above*/

Process 2:

Fun_Open()

sqlite3_open(DATABASE, );

sqlite3_exec(dbRead, " PRAGMA jouranl_mode = WAL", NULL, NULL, );

Fun_Read() on TblTest**
/* Do the periodic read operation by using db handler return from above*/

Cheers -
Techi


On Mon, Aug 26, 2013 at 12:14 PM, Dan Kennedy  wrote:

> On 08/26/2013 01:37 PM, techi eth wrote:
>
>> Hi,
>>
>> I come across database file locking error while trying below case with
>> Update.
>>
>> Case: One process is updating a Colum periodically & other process is
>> selecting same Colum or other colum in table periodically for read.
>> What is the best way to handle so that Update will not get locking error?
>>
>
> Using WAL mode.
>
> __**_
> 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] Database locking Error

2013-08-26 Thread Dan Kennedy

On 08/26/2013 01:37 PM, techi eth wrote:

Hi,

I come across database file locking error while trying below case with
Update.

Case: One process is updating a Colum periodically & other process is
selecting same Colum or other colum in table periodically for read.
What is the best way to handle so that Update will not get locking error?


Using WAL mode.

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