"Zachary Buckholz" <[EMAIL PROTECTED]> writes:

> But since my perl code runs from the crontab sometimes jobs overlap
> and I might be popping mail for more then one site's feedback address
> at a time and thus making multiple inserts into the MS SQL database
> server. Then I get these damn deadlock errors.

You probably need to read up on how MS SQL handles locking. Perhaps MS
SQL is using some kind of block-level locking? Deadlocks between two
processes P and Q are often caused by a scenario like

  1. P locks resource A (for example a disk block)
  2. Q locks resource B
  3. P needs B, and waits for Q to release it
  4. Q needs A, and waits for P to release it
  5. Deadlock!

Maybe by changing the way MS SQL does locking (eg. use row-level or
table-level locking) could eliminate the deadlocks.

I assume that your script does multiple inserts in the same transaction
(otherwise how could it deadlock?) If you performance constraints and
transaction semantics allow it, you might be able to avoid the problem
by committing after every insert.

> What's odd is I never get errors with MySQL, I can have all 11 site

I think MySQL locks the whole table by default, that would prevent
deadlock in this case.

> Also I am using FreeTDS and have been using the same drivers and
> FreeTDS for 3 years. Without problems.

FreeTDS doesn't allow placeholders, does it? But if it does, you should
switch to using them rather than $dbh->quote().

 - Kristian.

Reply via email to