Re: Problem with FileLock
- From: Gordon Beaton <n.o.t@xxxxxxxxx>
- Date: 14 Jul 2007 14:23:24 GMT
On Fri, 13 Jul 2007 14:34:14 -0700, alejandrina wrote:
We need to update a file (on a file server) from many different
machines. To synchromize the updates I am using FileLock.
Everything works as advertised (ie if a machine gets the lock, it
writes to the file while the other machines wait, everything is
written in the proper order). The same test, using Linux machines,
fails: the file is clobbered (meaning one update gets on top of
another). No Exceptions are thrown; in fact the debug statements
indicate that all the machines are acquiring the exclusive lock)
If you are accessing the files over NFS, then I believe (but am not
sure) that
- the locks may be unknown to the server, and consequently to other
NFS clients.
- each client might be caching its updates, which are not guaranteed
to be visible to other clients without a close/open sequence in
between (if even then). This could result in corruption even if the
locking is in fact working as you expect it to.
What happens when you run two instances of your application on the
*same* host?
I would recommend that you update the file from a single (server)
process that does so on behalf of the other (client) processes, so the
updates are atomic and strictly serialized, without any need for
locking.
/gordon
--
.
- Follow-Ups:
- Re: Problem with FileLock
- From: Nigel Wade
- Re: Problem with FileLock
- From: Lew
- Re: Problem with FileLock
- References:
- Problem with FileLock
- From: alejandrina
- Problem with FileLock
- Prev by Date: Re: Annotation on interface method argument
- Next by Date: Re: project
- Previous by thread: Re: Problem with FileLock
- Next by thread: Re: Problem with FileLock
- Index(es):
Relevant Pages
|