Re: multi-process locking



Chris Friesen <cbf123@xxxxxxxxxxxxx> writes:
Ivan Novick wrote:

From people's experience, what do you think is the best technique for
locking a shared resource between multiple processes? I have seen
people use the file system and even some people use a oracle DB.

This is a tricky issue to handle really well.

fcntl() (aka record locks) are automatically freed if the holding
process exits. This is both good and bad--it's good because someone
else can take the lock, it's bad because the resource could be in a
non-consistent state.

It is 'bad' when a processes crashes, leaving 'some shared ressource
in a non-consistent state'. And this badness doesn't get less bad by
forcing someone who hopefully knows about the traditional UNIX(*)
adversary to even barely robust locking schemes to intervent manually
before even detecting that the 'shared ressource is in an inconsistent
state' is possible.
.