Internal Server Error Mysql2::Error: Lock wait timeout exceeded; try restarting transaction

Hey all,

When running a cucumber test, I get this:

Internal Server Error
Mysql2::Error: Lock wait timeout exceeded; try restarting transaction:
INSERT INTO `users` (`address_1`, `address_2`, `address_3`,
`can_receive_sms`, `city`, `completed_terms_on`, `country_id`,
`created_at`, `current_sign_in_at`, `current_sign_in_ip`,
`department`, `email`, `encrypted_password`, `fax`, `first_name`,
`force_update_password`, `gender_id`, `invitation_accepted_at`,
`invitation_limit`, `invitation_sent_at`, `invitation_token`,
`invited_by_id`, `invited_by_type`, `last_name`, `last_sign_in_at`,
`last_sign_in_ip`, `middle_initial`, `mobile_phone`, `notes`,
`organization_id`, `organization_type`, `postal_code`,
`remember_created_at`, `reset_password_sent_at`,
`reset_password_token`, `sign_in_count`, `state_region`, `timecop`,
`timezone`, `title`, `tmp_password`, `user_state_id`, `user_type_id`,
`username`, `work_phone`) VALUES ('', '', '', 0, '', NULL, 1,
'2012-01-19 23:26:32', NULL, NULL, '', 'example1@verdacom.com', '$5a
$02$1/mAgbgewxsVz8MLh0B4ievdEeyASECbjMgCSAPwfv294MJUMwg0S', NULL,
'user1', 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'user1', NULL,
NULL, '', '', '', 1, 'Client', '', NULL, NULL, NULL, 0, '', 0,
'America/New_York', '', 'ADFCGCJ', 3, NULL, 'user1', '0432156789')

The test fails on this method:

def create_user(roles)

    page.execute_script("$('li#admin.has_nested
ul').css('display','block')")

    click_link 'Users'

    click_on 'New User'

    role = Role.find_by_key(roles)
    user = Factory.create :user, force_update_password: true, roles:
[role]

    site = Factory.create :site, site_state_id:
SiteState.find_by_key(:active).id
    user.organization = site
    user.save!

    %w{username email first_name last_name work_phone}.each do |field|
      fill_in "user_#{field}", with: user[field]
    end

    select_second_group_option 'organization'

    if roles.to_s.downcase == "site"
      check("user_force_update_password")
    end

    fill_in 'password', with: user.password

    select "America/New_York", from: 'user_timezone'
    select "#{role.name.camelcase}", from: 'user_role_ids'
    select "USA", from: 'user_country_id'

    click_on 'Create User'

    return user
  end

I tried the following already:

1)trying dumping and adding new database

2) tried modifying my.cnf log and added this:
TransactionDeadlockDetectionTimeout=10000
HeartbeatIntervalDbDb=3000
HeartbeatIntervalDbApi=3000

3) Copying the sql and running it in mysql directly worked fine so not
a problem with sql itself:
Query OK, 1 row affected (0.00 sec)

4) The following gives undefined method for some strange reason (even
though I copied directions):
ActiveRecord::Base.verification_timeout = 570

5) Tried using development database rather than test database

thanks for response