develooper Front page | perl.perl5.porters | Postings from November 2002

Re: edit <> files in place is not atomic

From:
Mark Jason Dominus
Date:
November 20, 2002 11:03
Subject:
Re: edit <> files in place is not atomic
Message ID:
20021120190351.3792.qmail@plover.com

> :Or fix it to be atomic ;-)
> 
> I don't think the possibility exists: at the point we have a complete
> file prepared to replace the original, it is still a non-atomic two
> step process to unlink the old file and replace it with the new.

If the new file is on the same filesystem as the old file, the
rename() call does precisely what we want.  No previous unlink() is
necessary.

> I'm not aware of any mechanism that would guarantee the original
> filename would point to valid data under every possible failure mode.

I have heard that the universe does not support atomic operations
(although I have not seen the code.)  If this is true, perhaps we
should report the bug to the manufacturer.

        DEFECT REPORT
        SDR #11-60903

        SYSTEM          VERSION COMPONENT
        Universe        2.5     Core

        It appears that there is an arbitrary limitation on the
        velocity with which the system is able to effect the internal
        transmission of information.  As a result, our applications
        are having synchronization problems and race conditions when
        used over long distances or brief intervals, and it is
        difficult to perform atomic updates of complex structures.

        Have we configured something incorrectly?  Also, we are having
        the most difficult time getting the electrons to stay where we
        put them.  They keep jumping all over the place.  Is this
        perhaps related?



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About