Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
There are mechanisms for locking tables. However, they vary greatly from database to database. This will work - but if you're already having load issues, this increases the database bottleneck by forcing everyone to wait, even if they wouldn't have collided, which could be disastrous.

It would be better to have a unique set of keys. You might not be able to have just one unique key, but you can specify a set of keys, so that you only get, say, one valid entry per customer per day. The second attempt to insert will throw a SQL error, so make sure you wrap the call in an eval and catch it. Ensuring database integrity with the right keys so you never get duplicate data where it would be inappropriate is a major design goal of any db table.

Also, you may (or may not, it's hard to tell) be able to do some rearchitecturing of your perl layer to stop the race conditions. If you're having load problems causing things to back up, there's probably other issues to consider, and it's time to think about performance tuning and perhaps different methodologies to get your job done.

-- Kirby, WhitePages.com


In reply to Re: Locking a database connection by kirbyk
in thread Locking a database connection by cosmicperl

Title:
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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-24 19:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found