Excellent information, tye, and yes, I would not consider using the haphazard solution I cobbled together described above for anything where a better mechanism could be found.

In the case where I did deploy this mockery, a friend had a web site where he'd used my original file locking module (which uses flock), and it had worked fine for, I seem to recall, years.

Then suddenly it would start issuing errors -- it's been a long time, but I have a vague recollection it was indicating something about running out of file handles or something.

Anyway, we pored over the code and added logging and could find no reason that made sense to us at the time to explain consuming file handles; the web host provider was absolutely useless in assisting on the troubleshooting, flatly refusing to share much of any information at all. They had no shell access, no help from the web host provider, and no logical explanation for the error. They were kind of boxed into a corner.

They needed their event registration page functional, and we were running out of time. So, we hastily threw some quick workaround ideas onto the table, decided on the monstrosity above, and coded it. It got them through the registration window, and then they switched web hosting providers, reverted back to using the module employing flock, and, as far as I know, they've had no further problems with it.

I think he'd later determined that they'd changed the underlying OS without telling any of their clients -- or something equally absurd. It's been too long ago; the details are gone. The monstrosity above got us through in a pinch.

Update: To answer your other point, I seem to recall $^Owas reporting an odd flavor of *nix whilst the problem was afoot. And for some reason BSD or NetBSD is ringing a bell. But I just don't have the details anymore.

Update 2: Another point; I've scanned my code repository going back to 2003. My last file-level locking code was in 2008, and it used the old module with flock. I don't see anywhere that I've used the beast I described above except in that one emergency. Thus, my original statement that I found something else and didn't have to go back appears to be me being misled by faulty memory; all serialization of activities since 2008 then have been done using database queueing systems.

It's weird, not having precise and seemingly infinite recall anymore. I've benefitted from that trait my whole life; it would seem I'm now a sitting duck for a number of old jokes about memory. :-)


In reply to Re^5: How to do atomic file locking? (KISS) by marinersk
in thread How to do atomic file locking? by Acapulco

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.