Thread: Mutex via database

Mutex via database

From
Enrico Weigelt
Date:
Hi folks,


i've a dozen of servers processing jobs from a database. 
Some servers may only run exactly once, otherwise I'll get jobs 
done twice. 

Is there any way for implementing an kind of mutex within the
database, which is automatically released if the holding 
process/connection dies ?


thx
-- 
---------------------------------------------------------------------Enrico Weigelt    ==   metux IT service phone:
+4936207 519931         www:       http://www.metux.de/ fax:       +49 36207 519932         email:
contact@metux.de
--------------------------------------------------------------------- Realtime Forex/Stock Exchange trading powered by
postgresSQL:))                                           http://www.fxignal.net/
 
---------------------------------------------------------------------


Re: Mutex via database

From
Markus Schaber
Date:
Hi, Enrico,

Enrico Weigelt wrote:

> i've a dozen of servers processing jobs from a database. 
> Some servers may only run exactly once, otherwise I'll get jobs 
> done twice. 
> 
> Is there any way for implementing an kind of mutex within the
> database, which is automatically released if the holding 
> process/connection dies ?

Use the "LOCK" sql command, possibly together with transaction isolation
set to serializable.

Markus