Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix for GRAILS-8433 using H2 database: increase H2 lock timeout from …

…1000 ms to 10000 ms
  • Loading branch information...
commit e392b71a08ca3dd586842aa24af34e1f06af713d 1 parent 1e47c4e
Lari Hotari lhotari authored
2  ...n-datasource/src/main/groovy/org/codehaus/groovy/grails/plugins/datasource/DataSourceGrailsPlugin.groovy
@@ -117,7 +117,7 @@ class DataSourceGrailsPlugin {
117 117 defaultReadOnly = readOnly
118 118 }
119 119
120   - url = ds.url ?: "jdbc:h2:mem:grailsDB;MVCC=TRUE"
  120 + url = ds.url ?: "jdbc:h2:mem:grailsDB;MVCC=TRUE;LOCK_TIMEOUT=10000"
121 121
122 122 String theUsername = ds.username ?: (defaultDriver ? "sa" : null)
123 123 if (theUsername != null) {
6 grails-resources/src/grails/grails-app/conf/DataSource.groovy
@@ -14,19 +14,19 @@ environments {
14 14 development {
15 15 dataSource {
16 16 dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
17   - url = "jdbc:h2:mem:devDb;MVCC=TRUE"
  17 + url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
18 18 }
19 19 }
20 20 test {
21 21 dataSource {
22 22 dbCreate = "update"
23   - url = "jdbc:h2:mem:testDb;MVCC=TRUE"
  23 + url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
24 24 }
25 25 }
26 26 production {
27 27 dataSource {
28 28 dbCreate = "update"
29   - url = "jdbc:h2:prodDb;MVCC=TRUE"
  29 + url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
30 30 pooled = true
31 31 properties {
32 32 maxActive = -1
6 ...te-uber/src/test/groovy/org/codehaus/groovy/grails/plugins/datasource/DataSourceGrailsPluginTests.groovy
@@ -141,7 +141,7 @@ class DataSourceGrailsPluginTests extends AbstractGrailsMockTests {
141 141 assertEquals "org.h2.Driver", parentBeanDef.propertyValues.getPropertyValue('driverClassName').value
142 142 assertEquals "sa", parentBeanDef.propertyValues.getPropertyValue('username').value
143 143 assertEquals "", parentBeanDef.propertyValues.getPropertyValue('password').value
144   - assertEquals "jdbc:h2:mem:grailsDB;MVCC=TRUE", parentBeanDef.propertyValues.getPropertyValue('url').value
  144 + assertEquals "jdbc:h2:mem:grailsDB;MVCC=TRUE;LOCK_TIMEOUT=10000", parentBeanDef.propertyValues.getPropertyValue('url').value
145 145 }
146 146
147 147 void testDataSourcePluginPoolingOn() {
@@ -373,7 +373,7 @@ class DataSourceGrailsPluginTests extends AbstractGrailsMockTests {
373 373 def config = new ConfigSlurper().parse '''
374 374 dataSource {
375 375 driverClassName = "org.h2.Driver"
376   - url = "jdbc:h2:mem:devDb;MVCC=TRUE"
  376 + url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
377 377 username = "sa"
378 378 password = ""
379 379 pooled = true
@@ -391,7 +391,7 @@ class DataSourceGrailsPluginTests extends AbstractGrailsMockTests {
391 391 assertEquals "org.h2.Driver", parentBeanDef.propertyValues.getPropertyValue('driverClassName').value
392 392 assertEquals "sa", parentBeanDef.propertyValues.getPropertyValue('username').value
393 393 assertEquals "", parentBeanDef.propertyValues.getPropertyValue('password').value
394   - assertEquals "jdbc:h2:mem:devDb;MVCC=TRUE", parentBeanDef.propertyValues.getPropertyValue('url').value
  394 + assertEquals "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000", parentBeanDef.propertyValues.getPropertyValue('url').value
395 395 }
396 396
397 397 private createAppCtx(config) {
4 scripts/Upgrade.groovy
@@ -151,8 +151,8 @@ move it to the new location of '${basedir}/test/integration'. Please move the di
151 151
152 152 def dsFile = new File(baseFile, "grails-app/conf/DataSource.groovy")
153 153 if (dsFile.exists() && argsMap.'update-data-source') {
154   - replace file:dsFile, token:"jdbc:hsqldb:mem:devDB", value:"jdbc:h2:mem:devDb;MVCC=TRUE"
155   - replace file:dsFile, token:"jdbc:hsqldb:mem:testDb",value: "jdbc:h2:mem:testDb;MVCC=TRUE"
  154 + replace file:dsFile, token:"jdbc:hsqldb:mem:devDB", value:"jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
  155 + replace file:dsFile, token:"jdbc:hsqldb:mem:testDb",value: "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
156 156 replace file:dsFile, token:"org.hsqldb.jdbcDriver", value:"org.h2.Driver"
157 157 }
158 158 // if Config.groovy exists and it does not contain values for

0 comments on commit e392b71

Please sign in to comment.
Something went wrong with that request. Please try again.