mysql - Unable to add an index on a field with InnoDB? -


All of that, I have an inaudible table on which I am trying to run an index and I get the following error Getting:

Deadlock found while trying to get the lock; Try restarting the transaction

The syntax is:

  optional table mytable ADD INDEX (fieldtoindex);  

As any ideas that will throw a deadlock error? Thanks!

You are not providing enough information to answer your question.

InnoDB, as a general rule, when an error occurs, see the production of Show Engine Inb position. You want to run it in the command line client, and end the command with \ G (backslash uppercase case) to make the output readable.

In your case, related information will be on top of the show engine INNODB status output, where it says something like

  ------------ ------------ Latest Defined Deadlock ----------------------- 100720 14:27:32 *** (1 ) Transactions: Transactions 3 572739397, Active 2 seconds, Process number 3057, OS Thread ID 1362831680 1, Lock 1 lock, 1 lock lock lock lock, Hap size 1216, 3 line lock, MySQL thread ID 37496388, query at the beginning of the index ID 1645924019 Host 10.147.209.20 DB Update Update Update Set Assistance = '4921 9 78' where id (302885, 303582, 303907,303911) *** (1) Waiting for this lock: Record Lock Space ID 36004 Page Number 147 N Bits 216 Index 'Primary' Table `db``t` tx id3 572739397 locks lock_mode x rec but does not wait for the gap Record lock, heap number 43 physical record: n_fields19; Compact format; Info bits 0  

This lists the relevant table and index names, as well as the statements included in it.

See also for more information.

If this happens more often, then look at the "D" screen (deadlock display).


Comments