Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Dear monks

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 ? cheers. I just wanted to thank everybody for taking the time and effort to read, think and post !! thanks.

In reply to avoiding a race by westy032001

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2023-11-29 11:16 GMT
Find Nodes?
    Voting Booth?

    No recent polls found