Description: SQL state: HYT00 Native error: 1213 SQL Errortext: Deadlock found when trying to get lock; try restarting transaction SQL STATEMENT: insert into OCHARTORGANIZATION (CORPID,MODIFIED,MODIFIER,ORGIID,PARENTIID) values(?,?,?,?,?) mysql> desc OCHARTORGANIZATION; +-----------+--------------+------+-----+-------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+--------------+------+-----+-------------------+----------------+ | CORPID | varchar(32) | YES | | NULL | | | MODIFIED | timestamp | YES | | CURRENT_TIMESTAMP | | | MODIFIER | varchar(255) | YES | | NULL | | | ORGIID | varchar(32) | | PRI | | | | PARENTIID | varchar(32) | YES | | NULL | | | SN | int(11) | | UNI | NULL | auto_increment | +-----------+--------------+------+-----+-------------------+----------------+ 6 rows in set (0.00 sec) client: OS fedora3 MyODBC3.51.10 unixODBC 2.2.9 server: OS RedHat Adavanced server3.0 MySQL max 4.1.10 My program use multi-threads to insert records into some tables by MyODBC. Each thread has one connection with AUTOCOMMIT OFF. When insert into other tables it's OK. Error occured when execute this statement concurrently: insert into OCHARTORGANIZATION (CORPID,MODIFIED,MODIFIER,ORGIID,PARENTIID) values(?,?,?,?,?) [EMAIL PROTECTED] mysql]$ cat /etc/odbcinst.ini [MySQL] Description = ODBC for MySQL Driver = /home/hyli/asterisk_software/MyODBC-3.51.10-pc-linux-i686/lib/libmyodbc3.so Setup = /usr/lib/libodbcmyS.so FileUsage = 1 If I only run one thread to insert all records, error won't occur. If my program connects to the local mysqld(on the same machine with my program), error won't occur. Local mysqld's version is also MySQL max 4.1.10 Before I added this code everything is OK. char autocommit[]="SET AUTOCOMMIT=0"; rc = SQLExecDirect(hstmtset,(SQLCHAR*)autocommit,sizeof(autocommit)-1); I really need some solution. Best regards, Gu Lei --
![]() |
- multi-thread insert into innodb table with auto_increment column ca... Gu Lei