Grails
  1. Grails
  2. GRAILS-8772

H2 version shipped w/Grails has bad bug, needs upgrade

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0 final
    • Fix Version/s: 2.0.2
    • Component/s: Persistence
    • Labels:
    • Environment:
      Grails 2.0.0
      Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11D50b)
      Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)
      H2 1.2.147

      Description

      The version of H2 in Grails is 1.2.147. This version has bug in the JDBC driver. Specifically, when using a remote H2 server (when the JDBC URL says something like "jdbc:h2:tcp:..."), whenever the application calls setAutoCommit(true), the driver actually sends "SET AUTOCOMMIT FALSE" to the database, and vice-versa. You can see the bug in the code for SessionRemote.java, in the trunk, prior to change r4059:

      http://code.google.com/p/h2database/source/detail?spec=svn4059&r=4059

      Needless to say it's pretty obnoxious to have the database set the auto commit state to the opposite of what you think it should be.

      At first, Grails appeared to work for me, because the database connection comes out of the pool with auto commit = true, and the scaffolding controllers don't use transactions (which turn off auto commit), and so the auto commit state never changed. But as soon as I introduced a service (which is transactional by default) things started getting weird. As soon as I called any service, suddenly the scaffolding stopped working. That's because my service set auto commit to false (making it true in the database), and then, when the connection was returned to the pool, DBCP set it to true (really making it false), where it remained for as long as the connection was in the pool, disabling any further updates made by the scaffolding controllers.

      It looks like this fix hasn't made it into an H2 release yet (it was just fixed about 4 weeks ago), but please update H2 as soon a a new release becomes available.

      A workaround in the meantime is to use a local H2 database, since the bug is only in the remote side of a TCP database connection.

        Issue Links

          Activity

          Hide
          Jeff Scott Brown added a comment -

          Willis,

          Do you know if this is fixed in 1.3.164?

          Show
          Jeff Scott Brown added a comment - Willis, Do you know if this is fixed in 1.3.164?
          Hide
          Willis Blackburn added a comment -

          I looked at that branch in SVN, and the bug was still there. The bug was only fixed about a month ago, and that release, although I think it came out after the bug was fixed, was probably branched off an finalized prior to that.

          Show
          Willis Blackburn added a comment - I looked at that branch in SVN, and the bug was still there. The bug was only fixed about a month ago, and that release, although I think it came out after the bug was fixed, was probably branched off an finalized prior to that.
          Hide
          Damir Murat added a comment -

          I believe it is fixed. I was looking at svn tag for version 1.3.164 (http://h2database.googlecode.com/svn/tags/version-1.3.164/h2/src/main/org/h2/engine/SessionRemote.java) and in the source code available with 1.3.164 download.

          Both contain a code emphasized above for revision 4059.

          Show
          Damir Murat added a comment - I believe it is fixed. I was looking at svn tag for version 1.3.164 ( http://h2database.googlecode.com/svn/tags/version-1.3.164/h2/src/main/org/h2/engine/SessionRemote.java ) and in the source code available with 1.3.164 download. Both contain a code emphasized above for revision 4059.
          Hide
          Willis Blackburn added a comment -

          You're right. I don't know why I thought the opposite. Maybe I looked at 1.3.163 by mistake?

          Show
          Willis Blackburn added a comment - You're right. I don't know why I thought the opposite. Maybe I looked at 1.3.163 by mistake?
          Hide
          Jeff Scott Brown added a comment -

          This upgrade may depend on the resolution of GRAILS-8444. When we upgrade H2 to 1.3.164, that problem shows up.

          Show
          Jeff Scott Brown added a comment - This upgrade may depend on the resolution of GRAILS-8444 . When we upgrade H2 to 1.3.164, that problem shows up.
          Hide
          Jeff Scott Brown added a comment -

          GRAILS-8444 has been resolved. I think we can move forward with this H2 upgrade now.

          Show
          Jeff Scott Brown added a comment - GRAILS-8444 has been resolved. I think we can move forward with this H2 upgrade now.

            People

            • Assignee:
              Jeff Scott Brown
              Reporter:
              Willis Blackburn
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development