I'm after some advice in avoiding a race condition for reading and possibly modifying a file or an alternate way of doing it.
The scenario is this , i have 300 processes connecting to a database at the same time every 15 mins, if these encounter a database error i want them to check a file to see if this error has been encountered before, if it hasn't it adds the error code with a time stamp, if it has been encountered before and the time stamp is greater than an hour ago it will mail the admin. The idea is to avoid getting 300 mails every 15 mins when somthing goes wrong.
As far as i can see i need to flock the file then read it, modify if necessary and then unlock, but this causes a bottle neck for my 300 processes is there a better way of doing things ?
I just wanted to thank everybody for taking the time and effort to read, think and post !!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||