Re: [sqlite] sqlite error: database is locked

2010-03-17 Thread imin imup
> Thanks for clarification. I assumed the error message of error code

> > SQLITE_BUSY is something like "databased is busy".
>
> http://www.sqlite.org/c3ref/c_abort.html
> Also in sqlite3.h file - comments on the right are almost exactly
> reflect the corresponding error message.
>

You are totally right.


>
> > Another newbie question. Is it safe for 2 threads to share 1 connection
> when
> > the connection is protected by my own mutex?
>
> Sure, everything protected by mutex can be considered executing in one
> thread and thus is never prone to multi-threading issues.
>
> Thanks for pointing out, very appreciated.
I'll restructure the code.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite error: database is locked

2010-03-17 Thread Pavel Ivanov
> Thanks for clarification. I assumed the error message of error code
> SQLITE_BUSY is something like "databased is busy".

http://www.sqlite.org/c3ref/c_abort.html
Also in sqlite3.h file - comments on the right are almost exactly
reflect the corresponding error message.

> Another newbie question. Is it safe for 2 threads to share 1 connection when
> the connection is protected by my own mutex?

Sure, everything protected by mutex can be considered executing in one
thread and thus is never prone to multi-threading issues.


Pavel

On Wed, Mar 17, 2010 at 3:00 PM, imin imup  wrote:
>> According to documents, sqlite_busy will happen if new reader cannot get
>
>> > shared_lock or new writer cannot get reserved_lock.
>> > I didn't see sqlite_busy error from my application.
>>
>> I didn't understand this. "database is locked" is SQLITE_BUSY.
>>
> Thanks for clarification. I assumed the error message of error code
> SQLITE_BUSY is something like "databased is busy".
>
>>
>> > Does this mean I need to close the current database connection before I
>> can
>> > make the next connection to same database file even through they are not
>> > shared?
>>
>> No, you can have several connections in one thread if you want.
>>
>> > Though it is not shared, it seems there may be cases where more
>> > than 1 database connections are held (in nested function calls). Will
>> this
>> > cause any issue?
>>
>> This can definitely be the issue. Consider this scenario:
>> - open connection 1;
>> - start executing some query on connection 1 - call sqlite3_step() but
>> it didn't return SQLITE_DONE yet;
>> - open connection 2;
>> - execute some update/insert/delete on connection 2
>>
>> In this case you have active statement on connection 1 that holds
>> SHARED lock on the database. And it will prevent any other connections
>> from writing. So connection 2 cannot obtain EXCLUSIVE lock, you get
>> SQLITE_BUSY without any chances to succeed.
>>
>
> Very good point. It seems one connection per function can be error prone.
> One long-lived connection per thread might be better.
>
> Another newbie question. Is it safe for 2 threads to share 1 connection when
> the connection is protected by my own mutex?
>
> Thanks a lot.
>
>
>>
>> Pavel
>>
>> On Wed, Mar 17, 2010 at 1:35 PM, imin imup  wrote:
>> > Thanks for help. As a novel sqlite user, it seems I need more.
>> >
>> > According to documents, sqlite_busy will happen if new reader cannot get
>> > shared_lock or new writer cannot get reserved_lock.
>> > I didn't see sqlite_busy error from my application.
>> >
>> > My usage is that:
>> > single process, multi-thread, multi-database files
>> >
>> > multi-database files
>> > I divided the tables into 2 database files to "increase" concurrency. A
>> > thread may open two database file at same time, but two database never
>> > appear in one sql statement. Is this likely to cause any issue?
>> >
>> > about "one connection per thread"
>> > Does this mean I need to close the current database connection before I
>> can
>> > make the next connection to same database file even through they are not
>> > shared?
>> > I tend to use short-lived database connections locally defined within
>> each
>> > function. Though it is not shared, it seems there may be cases where more
>> > than 1 database connections are held (in nested function calls). Will
>> this
>> > cause any issue?
>> >
>> > On Wed, Mar 17, 2010 at 11:05 AM, Pavel Ivanov 
>> wrote:
>> >
>> >> http://www.sqlite.org/faq.html#q5
>> >> http://www.sqlite.org/lockingv3.html
>> >>
>> >> Pavel
>> >>
>> >> On Wed, Mar 17, 2010 at 11:46 AM, imin imup  wrote:
>> >> > Hello users,
>> >> >
>> >> > I'm using sqlite 3.6.12 in muti-threaded application. I'm getting
>> sqlite
>> >> > errors occasionally.
>> >> > The error message is
>> >> >
>> >> > *sqlite error: database is locked*
>> >> >
>> >> > could someone explain to me what happened and what to be done? or
>> point
>> >> me
>> >> > to a document on how to fix this?
>> >> >
>> >> > Best
>> >> >
>> >> > Imin
>> >> > ___
>> >> > 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
>>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sql

Re: [sqlite] sqlite error: database is locked

2010-03-17 Thread imin imup
> According to documents, sqlite_busy will happen if new reader cannot get

> > shared_lock or new writer cannot get reserved_lock.
> > I didn't see sqlite_busy error from my application.
>
> I didn't understand this. "database is locked" is SQLITE_BUSY.
>
Thanks for clarification. I assumed the error message of error code
SQLITE_BUSY is something like "databased is busy".

>
> > Does this mean I need to close the current database connection before I
> can
> > make the next connection to same database file even through they are not
> > shared?
>
> No, you can have several connections in one thread if you want.
>
> > Though it is not shared, it seems there may be cases where more
> > than 1 database connections are held (in nested function calls). Will
> this
> > cause any issue?
>
> This can definitely be the issue. Consider this scenario:
> - open connection 1;
> - start executing some query on connection 1 - call sqlite3_step() but
> it didn't return SQLITE_DONE yet;
> - open connection 2;
> - execute some update/insert/delete on connection 2
>
> In this case you have active statement on connection 1 that holds
> SHARED lock on the database. And it will prevent any other connections
> from writing. So connection 2 cannot obtain EXCLUSIVE lock, you get
> SQLITE_BUSY without any chances to succeed.
>

Very good point. It seems one connection per function can be error prone.
One long-lived connection per thread might be better.

Another newbie question. Is it safe for 2 threads to share 1 connection when
the connection is protected by my own mutex?

Thanks a lot.


>
> Pavel
>
> On Wed, Mar 17, 2010 at 1:35 PM, imin imup  wrote:
> > Thanks for help. As a novel sqlite user, it seems I need more.
> >
> > According to documents, sqlite_busy will happen if new reader cannot get
> > shared_lock or new writer cannot get reserved_lock.
> > I didn't see sqlite_busy error from my application.
> >
> > My usage is that:
> > single process, multi-thread, multi-database files
> >
> > multi-database files
> > I divided the tables into 2 database files to "increase" concurrency. A
> > thread may open two database file at same time, but two database never
> > appear in one sql statement. Is this likely to cause any issue?
> >
> > about "one connection per thread"
> > Does this mean I need to close the current database connection before I
> can
> > make the next connection to same database file even through they are not
> > shared?
> > I tend to use short-lived database connections locally defined within
> each
> > function. Though it is not shared, it seems there may be cases where more
> > than 1 database connections are held (in nested function calls). Will
> this
> > cause any issue?
> >
> > On Wed, Mar 17, 2010 at 11:05 AM, Pavel Ivanov 
> wrote:
> >
> >> http://www.sqlite.org/faq.html#q5
> >> http://www.sqlite.org/lockingv3.html
> >>
> >> Pavel
> >>
> >> On Wed, Mar 17, 2010 at 11:46 AM, imin imup  wrote:
> >> > Hello users,
> >> >
> >> > I'm using sqlite 3.6.12 in muti-threaded application. I'm getting
> sqlite
> >> > errors occasionally.
> >> > The error message is
> >> >
> >> > *sqlite error: database is locked*
> >> >
> >> > could someone explain to me what happened and what to be done? or
> point
> >> me
> >> > to a document on how to fix this?
> >> >
> >> > Best
> >> >
> >> > Imin
> >> > ___
> >> > 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
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite error: database is locked

2010-03-17 Thread Pavel Ivanov
> According to documents, sqlite_busy will happen if new reader cannot get
> shared_lock or new writer cannot get reserved_lock.
> I didn't see sqlite_busy error from my application.

I didn't understand this. "database is locked" is SQLITE_BUSY.

> Does this mean I need to close the current database connection before I can
> make the next connection to same database file even through they are not
> shared?

No, you can have several connections in one thread if you want.

> Though it is not shared, it seems there may be cases where more
> than 1 database connections are held (in nested function calls). Will this
> cause any issue?

This can definitely be the issue. Consider this scenario:
- open connection 1;
- start executing some query on connection 1 - call sqlite3_step() but
it didn't return SQLITE_DONE yet;
- open connection 2;
- execute some update/insert/delete on connection 2

In this case you have active statement on connection 1 that holds
SHARED lock on the database. And it will prevent any other connections
from writing. So connection 2 cannot obtain EXCLUSIVE lock, you get
SQLITE_BUSY without any chances to succeed.


Pavel

On Wed, Mar 17, 2010 at 1:35 PM, imin imup  wrote:
> Thanks for help. As a novel sqlite user, it seems I need more.
>
> According to documents, sqlite_busy will happen if new reader cannot get
> shared_lock or new writer cannot get reserved_lock.
> I didn't see sqlite_busy error from my application.
>
> My usage is that:
> single process, multi-thread, multi-database files
>
> multi-database files
> I divided the tables into 2 database files to "increase" concurrency. A
> thread may open two database file at same time, but two database never
> appear in one sql statement. Is this likely to cause any issue?
>
> about "one connection per thread"
> Does this mean I need to close the current database connection before I can
> make the next connection to same database file even through they are not
> shared?
> I tend to use short-lived database connections locally defined within each
> function. Though it is not shared, it seems there may be cases where more
> than 1 database connections are held (in nested function calls). Will this
> cause any issue?
>
> On Wed, Mar 17, 2010 at 11:05 AM, Pavel Ivanov  wrote:
>
>> http://www.sqlite.org/faq.html#q5
>> http://www.sqlite.org/lockingv3.html
>>
>> Pavel
>>
>> On Wed, Mar 17, 2010 at 11:46 AM, imin imup  wrote:
>> > Hello users,
>> >
>> > I'm using sqlite 3.6.12 in muti-threaded application. I'm getting sqlite
>> > errors occasionally.
>> > The error message is
>> >
>> > *sqlite error: database is locked*
>> >
>> > could someone explain to me what happened and what to be done? or point
>> me
>> > to a document on how to fix this?
>> >
>> > Best
>> >
>> > Imin
>> > ___
>> > 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] sqlite error: database is locked

2010-03-17 Thread imin imup
Thanks for help. As a novel sqlite user, it seems I need more.

According to documents, sqlite_busy will happen if new reader cannot get
shared_lock or new writer cannot get reserved_lock.
I didn't see sqlite_busy error from my application.

My usage is that:
single process, multi-thread, multi-database files

multi-database files
I divided the tables into 2 database files to "increase" concurrency. A
thread may open two database file at same time, but two database never
appear in one sql statement. Is this likely to cause any issue?

about "one connection per thread"
Does this mean I need to close the current database connection before I can
make the next connection to same database file even through they are not
shared?
I tend to use short-lived database connections locally defined within each
function. Though it is not shared, it seems there may be cases where more
than 1 database connections are held (in nested function calls). Will this
cause any issue?

On Wed, Mar 17, 2010 at 11:05 AM, Pavel Ivanov  wrote:

> http://www.sqlite.org/faq.html#q5
> http://www.sqlite.org/lockingv3.html
>
> Pavel
>
> On Wed, Mar 17, 2010 at 11:46 AM, imin imup  wrote:
> > Hello users,
> >
> > I'm using sqlite 3.6.12 in muti-threaded application. I'm getting sqlite
> > errors occasionally.
> > The error message is
> >
> > *sqlite error: database is locked*
> >
> > could someone explain to me what happened and what to be done? or point
> me
> > to a document on how to fix this?
> >
> > Best
> >
> > Imin
> > ___
> > 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] sqlite error: database is locked

2010-03-17 Thread Pavel Ivanov
http://www.sqlite.org/faq.html#q5
http://www.sqlite.org/lockingv3.html

Pavel

On Wed, Mar 17, 2010 at 11:46 AM, imin imup  wrote:
> Hello users,
>
> I'm using sqlite 3.6.12 in muti-threaded application. I'm getting sqlite
> errors occasionally.
> The error message is
>
> *sqlite error: database is locked*
>
> could someone explain to me what happened and what to be done? or point me
> to a document on how to fix this?
>
> Best
>
> Imin
> ___
> 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] sqlite error: database is locked

2010-03-17 Thread imin imup
Hello users,

I'm using sqlite 3.6.12 in muti-threaded application. I'm getting sqlite
errors occasionally.
The error message is

*sqlite error: database is locked*

could someone explain to me what happened and what to be done? or point me
to a document on how to fix this?

Best

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


RE: [sqlite] SQLite error: Database is locked

2006-11-22 Thread Denis Povshedny
Hi Rama!

Unfortunatelly I haven't any experience with Linux. But I reproduce
situation on my system (Win XP), and have noticed that after kiliing
Process A files 

~testDb.db3 
~testDb.db3-journal 

are usable for Process B. Process B just reuse file ~testDb.db3-journal
file for own needs, and everything is fine. Maybe you shall check, is
Process A and all their libraries really unloaded from memory? Isn't it
just a file locking, is it? For example, can you simply move/delete
database file after trap Process A, or it will be locked by system.

Good luck!
Denis

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 21, 2006 6:43 PM
To: sqlite-users@sqlite.org
Subject: RE: [sqlite] SQLite error: Database is locked


Hi Denis,

Thanks to  your reply.
Iam using the Linux 2.6.9.34 EL and sqlite version 3.3.6.
your solution is good , but in my case the scenario is like this

process A opens the connection and begins the transaction
A inserts to the database 
A calls other function that are related to internal operations.
Depending on the return value of the function, It commits or rollback's 
the DB.


Thanks,
 Rama Raju


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