You're basically just moving the race condition, which often happens when trying to avoid races.
You've gotten suggestions that can surely help, such as locking the lock table. That type of solution can have significant problems when some process dies unexpectedly and the lock isn't removed. Perhaps you'll have a cleanup script that removes dead locks or some such.
How about considering implementing something like common version control systems use, Optimistic_concurrency_control (or "optimistic locking" which Wikipedia tells me is a misnomer). Time stamp or version updates to data; when updates conflict, ask the user creating the conflict to fix it. The idea being that conflicts are uncommon.
Only you know your application, so I may be talking out of my hat. However, you may find you're going to extreme ends to account for a circumstance that rarely occurs.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.