Hi,

I sent the following e-mail to the msql-mysql-modules list earlier today 
regarding a deadlock error using DBD::mysql.

I was advised by Jochen Wiedmann that DBD::mysql is simply a thin layer 
on top of the C interface, and that I should therefore forward my 
problem to this list, so here goes...

---

I'm experiencing deadlock errors on BDB tables when using DBD::mysql. 
I've whittled it down to an unbelievably simple program:

------------------------------
use strict;
use warnings;

use DBI;

my $dbh = DBI->connect('dbi:mysql:test', 'root', '',
            {AutoCommit => 0, PrintError => 0, RaiseError => 1});

for (my $i = 0; ; $i++) {
    print "i = $i\n";

    my $sth = $dbh->prepare("INSERT INTO x (id) VALUES ($i)");
    $sth->execute();
    $sth->finish();

    $dbh->commit();
}

$dbh->disconnect();
------------------------------

I use the following batch file to (re-)create the database which this 
program uses:

------------------------------
@echo off
\mysql\bin\mysqladmin -f drop test >NUL 2>&1
\mysql\bin\mysqladmin create test
\mysql\bin\mysql -u root -e "CREATE TABLE x (id INT) TYPE=BDB" test
------------------------------

The program runs fine on its own, but when I run two of them together, 
one of them deadlocks in a matter of seconds.

The error is:
DBD::mysql::st execute failed: Deadlock found when trying to get lock; 
Try restarting transaction at D:\Temp\deadlock.pl line 14.

I can't understand why this program should have deadlock errors in the 
first place, but what is even stranger (and is why I'm mailing to *this* 
list) is that it runs fine if I use DBD::ADO instead of DBD::mysql.  (I 
also tried DBD::ODBC; that had the same deadlock errors as DBD::mysql.) 
However, I'm not keen to use the DBD::ADO driver because it doesn't 
(currently) support bind parameters, which I'm making much use of.

Also, the same program with only the DBI connect string changed to 
access a Sybase database works fine with the main Sybase DBD driver 
(DBD::ASAny) and with DBD::ADO and DBD::ODBC.

Any help would be greatly appreciated.

Steve Hay

---

Version info:

OS: Windows NT4, SP6
Perl: 5.6.1, patched to the same level as ActivePerl Build 631
DBI: 1.21
DBD::mysql: 2.1013
DBD::ADO: 2.4
DBD::ODBC: 0.40
MySQL: 3.23.49a-max-nt
MyODBC: 2.50.39



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to