When a transaction is waiting for a resource, it will wait for the resource to become free, or stop waiting and return with the error
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
      The length of time a transaction will wait for a resource before
      “giving up” is determined by the value of the
      configuration parameter innodb_lock_wait_timeout.  The default
      setting for this parameter is 50 seconds. The minimum setting is
      1 second, and values above 100,000,000 disable the timeout, so a
      transaction will wait “forever”.  Following a
      timeout, the SQL statement that was executing will be rolled
      back.  (In MySQL 5.0.12 and earlier, the transaction rolled
      back.)  The user application may try the statement again
      (usually after waiting for a while), or rollback the entire
      transaction and restart.
Before InnoDB Plugin 1.0.2, the only way to set this
      parameter was in the MySQL option file
      (my.cnf or my.ini), and
      changing it required shutting down and restarting the server.
      Beginning with the InnoDB Plugin 1.0.2, the configuration
      parameter innodb_lock_wait_timeout can be set at runtime with
      the SET GLOBAL or SET
      SESSION commands.  Changing the
      GLOBAL setting requires the
      SUPER privilege and affects the operation of
      all clients that subsequently connect.  Any client can change
      the SESSION setting for
      innodb_lock_wait_timeout, which affects only that
      client.
This is the User’s Guide for InnoDB Plugin 1.0.6 for MySQL 5.1, generated on March 4, 2010 (rev 673:680M).

