1

I have tried for days without success to update the records in my MySQL database using grails. I always get a java.sql.SQLException which is caused by:

Lock wait timeout exceeded

Here is the code I am using:

def campaignUpdater(id, details){
def dbData = Campaigns.get(id)
if(dbData){
      dbData.totalSent = details.totalSent
      dbData.totalQueued = details.totalQueued
      dbData.totalFailed = details.totalFailed
      dbData.uniqueClickers = details.uniqueClickers
      dbData.opened = details.opened
      dbData.save(flush: true, failOnError: true)
      return true
  }else
    return false
}

I really need help as soon as possible.

tim_yates
  • 167,322
  • 27
  • 342
  • 338

1 Answers1

0

Lock wait timeout exceeded exception is either caused if there is a deadlock and Mysql is unable to detect it, or if you have a very long running query.

You probably have a InnoDB engine problem. Most likely you'll need to kill some processes inorder for your queries to run properly. See these answers for more info.

Community
  • 1
  • 1
Gherbi Hicham
  • 2,416
  • 4
  • 26
  • 41
  • It's hard to know what the problem is from the code when it comes to transactions in a database, I did some research and I edited my answer I hope it will help you solve the problem. – Gherbi Hicham Jul 16 '16 at 19:11