groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acefael <>
Subject Sql Concurrency Issue?
Date Fri, 13 Nov 2015 10:44:23 GMT

hi Guillaume, hi Everyone,

first: thanks for making Groovy! It simply is great!

I am using groovy.sql.Sql with a commons dbcp2 BasicDataSource and am encountering a stacktrace
as in [2] below.  I do create many identical closures with different data, and I pass them
all at once to ExecutorService.invokeAll.  The closures are all using the same Sql instance.

I believe this is a race condition because it happens only when the database is over a network,
and not when the database is local.

To work around I can set Sql.cacheNamedQueries = false.  Problem is reliably gone in this
case.  So I guess the culprit is in [1], with my sql already being cached in namedParamSqlCache,
but not yet in namedParamIndexPropCache?


[1] the line in the source code

[2] the stacktrace

	at java.util.ArrayList.<init>( ~[?:1.8.0]
	at groovy.sql.Sql.buildSqlWithIndexedProps( ~[groovy-all-2.4.5.jar:2.4.5]
	at groovy.sql.Sql.checkForNamedParams( ~[groovy-all-2.4.5.jar:2.4.5]
	at groovy.sql.Sql.getPreparedStatement( ~[groovy-all-2.4.5.jar:2.4.5]
	at groovy.sql.Sql.getPreparedStatement( ~[groovy-all-2.4.5.jar:2.4.5]
	at groovy.sql.Sql.execute( ~[groovy-all-2.4.5.jar:2.4.5]
	at groovy.sql.Sql.execute( ~[groovy-all-2.4.5.jar:2.4.5]
	at groovy.sql.Sql$execute$ Source) ~[?:?]
	at es.acefael.BaseMigration.execute(BaseMigration.groovy:2017) ~[es-acefael-dostuff-SNAPSHOT.jar:?]

View raw message