Re: [sqlite] sqlite & multi process usage

2014-07-18 Thread Howard Chu

Richard Hipp wrote:

On Thu, Jul 17, 2014 at 5:10 AM, Micka  wrote:


Well,

All of my process are using Mutex to protect sqlite from concurrent access.



What kind of mutex are you using that works across processs?  All the
mutexes I know about only work for a single process.

pthreads supports process-shared mutexes. 
http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_mutexattr_getpshared.html


BerkeleyDB and LMDB use these to support multi-process access to a DB, which 
is why their forks of SQLite3 also support multi-process access.


It seems that FreeBSD and other related BSDs still don't implement these 
though, so you have to use semaphores on them instead. (Either SysV style or 
POSIX named semaphores.)


--
  -- Howard Chu
  CTO, Symas Corp.   http://www.symas.com
  Director, Highland Sun http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite & multi process usage

2014-07-18 Thread Micka
Sorry, I mean semaphore => sem_open(pszSemaphoreName, O_CREAT, S_IRWXU |
S_IRWXG | S_IRWXO, 0);


On Fri, Jul 18, 2014 at 11:45 AM, Richard Hipp  wrote:

> On Thu, Jul 17, 2014 at 5:10 AM, Micka  wrote:
>
> > Well,
> >
> > All of my process are using Mutex to protect sqlite from concurrent
> access.
> >
>
> What kind of mutex are you using that works across processs?  All the
> mutexes I know about only work for a single process.
>
> --
> 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] sqlite & multi process usage

2014-07-18 Thread Richard Hipp
On Thu, Jul 17, 2014 at 5:10 AM, Micka  wrote:

> Well,
>
> All of my process are using Mutex to protect sqlite from concurrent access.
>

What kind of mutex are you using that works across processs?  All the
mutexes I know about only work for a single process.

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


Re: [sqlite] sqlite & multi process usage

2014-07-17 Thread Simon Slavin

On 17 Jul 2014, at 10:10am, Micka  wrote:

> Well,
> 
> All of my process are using Mutex to protect sqlite from concurrent access.
> 
> That why I don't understand why I get SQLITE_BUSY error .
> 
> Micka,
> 
> 
> On Tue, Jul 8, 2014 at 11:44 PM, Simon Slavin  wrote:
> 
>> Have you set a timeout

Did you set a timeout period for that connection ?

If you didn't set a timeout, then the database API call will try once to open 
the file, find that it has a MUTEX lock, and fail, giving you SQLITE_BUSY.

If you do set a timeout, then the database API call will try once to open the 
file, find that it has a MUTEX lock, and keep checking the lock until your 
timeout period has passed.

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


Re: [sqlite] sqlite & multi process usage

2014-07-17 Thread Micka
Well,

All of my process are using Mutex to protect sqlite from concurrent access.

That why I don't understand why I get SQLITE_BUSY error .

Micka,


On Tue, Jul 8, 2014 at 11:44 PM, Simon Slavin  wrote:

>
> On 8 Jul 2014, at 8:39pm, Micka  wrote:
>
> > i'm using sqlite in different process. Sometimes I got the error Busy
> ... =>
> >
> > When SQLite tries to access a file that is locked by another process, the
> > default behavior is to return SQLITE_BUSY.
> >
> >
> > So how can I prevent that ?
>
> Have you set a timeout, so that SQLite can back off for a little time then
> try again ?
>
> Use either
>
> 
>
> or
>
> 
>
> 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] sqlite & multi process usage

2014-07-08 Thread Simon Slavin

On 8 Jul 2014, at 8:39pm, Micka  wrote:

> i'm using sqlite in different process. Sometimes I got the error Busy ... =>
> 
> When SQLite tries to access a file that is locked by another process, the
> default behavior is to return SQLITE_BUSY.
> 
> 
> So how can I prevent that ?

Have you set a timeout, so that SQLite can back off for a little time then try 
again ?

Use either



or



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


[sqlite] sqlite & multi process usage

2014-07-08 Thread Micka
Hi,

i'm using sqlite in different process. Sometimes I got the error Busy ... =>

When SQLite tries to access a file that is locked by another process, the
default behavior is to return SQLITE_BUSY.


So how can I prevent that ?  you said :

When any process wants to write, it must lock the entire database file for
the duration of its update.

Thx you very much,
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users