Samo
Samo

Reputation: 8240

Grails transaction never completes

Consider the code below, that tries to create a new SerpKeyword within a transaction and prints to the console to show where it is.

    if (!serpKeyword) {
        println "I DIDN'T FIND THE KEYWORD!"
        SerpKeyword.withNewTransaction {
            println "SO NOW I'M BEGINNING A TRANSACTION"
            serpKeyword = new SerpKeyword(
                    keyword: searchKeyword,
                    geoKeyword: geoKeyword,
                    concatenation: concatenation,
                    locale: locale
            )
            println "NOW I'LL SAVE THE KEYWORD"
            serpKeyword.save(failOnError: true, flush: true)
            println "AND NOW THE KEYWORD IS SAVED"
        }
    }

The console output I see right away is:

I DIDN'T FIND THE KEYWORD!
SO NOW I'M BEGINNING A TRANSACTION
NOW I'LL SAVE THE KEYWORD

I never see the last line of my output, indicating that the record never saves. I've tried this both with and without the options that I'm passing into save. Regardless, it just hangs for a while, and eventually I get this stacktrace:

Got error -1 from storage engine. Stacktrace follows:
java.sql.SQLException: Got error -1 from storage engine
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2019)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
    at com.reachlocal.grails.sales.AdvertiserConnectionService$_findOrCreateSerpKeyword_closure9$$EO2A9QHA.doCall(AdvertiserConnectionService.groovy:624)
    at org.grails.datastore.gorm.GormStaticApi.withNewTransaction(GormStaticApi.groovy:696)
    at com.reachlocal.grails.sales.AdvertiserConnectionService$$EO2A9QHA.findOrCreateSerpKeyword(AdvertiserConnectionService.groovy:615)
    at com.reachlocal.grails.sales.AdvertiserConnectionService$$EO2A9QHA.createSerpEntryForKeyword(AdvertiserConnectionService.groovy:659)
    at com.reachlocal.grails.sales.AdvertiserConnectionService$$EO2A9QHA.addKeyword(AdvertiserConnectionService.groovy:51)
    at com.reachlocal.grails.serp.SerpController$_closure9.doCall(SerpController.groovy:77)
    at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
    at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
    at org.jasig.cas.client.session.SingleSignOutFilter.doFilter(SingleSignOutFilter.java:65)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:680)

What gives?

Upvotes: 0

Views: 369

Answers (2)

dmahapatro
dmahapatro

Reputation: 50275

Do you have the id generation strategy set as assigned any thing other than a sequence/auto in the domain class serpKeyword?

It will be helpful to debug if you can add the domain class in the post as well.

Upvotes: 0

Dror Bereznitsky
Dror Bereznitsky

Reputation: 20386

You may get the "Got error -1 from storage engine" for several reasons:

  1. Your database is out of disk space
  2. You have the innodb_force_recovery switch in your my.cnf file
  3. Mismatched MySQL tablespace ids.

The best way to troubleshoot this issue is to take a look at the MySQL error log

Upvotes: 1

Related Questions