in reply to Re^4: How to do atomic file locking? (KISS)
in thread How to do atomic file locking?
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. :-)
|
|---|