The issue is not about _this_ record, but that you may have screwed up another process trying to handle the _next_ one. I think this would happen only if you took more than 3 seconds to process the record, so that the next process may see that the timestamp is old and grab it anyway: if it gets the LOCK_EX in the interval between you closing the file and unlinking it, it will merrily truncate and rewrite the file without knowing that anything has changed under its feet.

It may be that the effect under Win32 would be that the unlink() fails, so that the new process really does have the actual file still. On a *nix system, I think it would instead have a locked filehandle on a file that is no longer linked on the filesystem, and would therefore be in danger of clashing with the next process to come and get a lock.

However truncating instead should (I think) be safe either way round.

Hugo


In reply to Re^5: Frustration with changing lock type by hv
in thread Frustration with changing lock type by demerphq

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.