Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Disable OPTIMIZE_REUSE_RESULTS #1007

Merged
merged 2 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ object JdbcProjectionSpec {

lazy val conn = {
Class.forName("org.h2.Driver")
val c = DriverManager.getConnection("jdbc:h2:mem:jdbc-projection-test;DB_CLOSE_DELAY=-1")
val c =
DriverManager.getConnection("jdbc:h2:mem:jdbc-projection-test;DB_CLOSE_DELAY=-1;OPTIMIZE_REUSE_RESULTS=FALSE")
c.setAutoCommit(false)
c
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static class PureJdbcSession implements JdbcSession {
public PureJdbcSession() {
try {
Class.forName("org.h2.Driver");
Connection c = DriverManager.getConnection("jdbc:h2:mem:test-java;DB_CLOSE_DELAY=-1");
Connection c = DriverManager.getConnection("jdbc:h2:mem:test-java;DB_CLOSE_DELAY=-1;OPTIMIZE_REUSE_RESULTS=FALSE");
c.setAutoCommit(false);
this.connection = c;
} catch (ClassNotFoundException | SQLException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ object JdbcOffsetStoreSpec {
def jdbcSessionFactory(): PureJdbcSession =
new PureJdbcSession(() => {
Class.forName("org.h2.Driver")
val conn = DriverManager.getConnection("jdbc:h2:mem:offset-store-test-jdbc;DB_CLOSE_DELAY=-1")
// OPTIMIZE_REUSE_RESULTS=FALSE needed as workaround for H2 bug, see https://github.com/akka/akka-projection/issues/992
val conn = DriverManager.getConnection(
"jdbc:h2:mem:offset-store-test-jdbc;DB_CLOSE_DELAY=-1;OPTIMIZE_REUSE_RESULTS=FALSE")
conn.setAutoCommit(false)
conn
})
Expand Down
2 changes: 1 addition & 1 deletion akka-projection-slick/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ akka.projection.slick {

# add here your Slick db settings
db {
# url = "jdbc:h2:mem:test1"
# url = "jdbc:h2:mem:test1;OPTIMIZE_REUSE_RESULTS=FALSE"
# driver = org.h2.Driver
# connectionPool = disabled
# keepAliveConnection = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,19 @@ object SlickOffsetStoreSpec {
val tag = TestTags.InMemoryDb

override def config: Config =
ConfigFactory.parseString("""
ConfigFactory
.parseString("""
akka.projection.slick {
profile = "slick.jdbc.H2Profile$"
db {
url = "jdbc:h2:mem:offset-store-test-slick;DB_CLOSE_DELAY=-1"
url = "jdbc:h2:mem:offset-store-test-slick;DB_CLOSE_DELAY=-1;OPTIMIZE_REUSE_RESULTS=FALSE"
driver = org.h2.Driver
connectionPool = disabled
keepAliveConnection = true
}
}
""").withFallback(baseConfig)
""")
.withFallback(baseConfig)

override def stopContainer(): Unit = ()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ import slick.dbio.DBIOAction
import slick.jdbc.H2Profile

object SlickProjectionSpec {
def config: Config = ConfigFactory.parseString("""
def config: Config =
ConfigFactory.parseString("""
akka {
loglevel = "DEBUG"
projection.slick {
Expand All @@ -64,7 +65,7 @@ object SlickProjectionSpec {

# TODO: configure connection pool and slick async executor
db {
url = "jdbc:h2:mem:slick-projection-test;DB_CLOSE_DELAY=-1"
url = "jdbc:h2:mem:slick-projection-test;DB_CLOSE_DELAY=-1;OPTIMIZE_REUSE_RESULTS=FALSE"
driver = org.h2.Driver
connectionPool = disabled
keepAliveConnection = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class PlainJdbcSession implements JdbcSession {
public PlainJdbcSession() {
try {
Class.forName("org.h2.Driver");
this.connection = DriverManager.getConnection("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
this.connection = DriverManager.getConnection("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;OPTIMIZE_REUSE_RESULTS=FALSE");
connection.setAutoCommit(false);
} catch (ClassNotFoundException | SQLException e) {
throw new RuntimeException(e);
Expand Down
2 changes: 1 addition & 1 deletion examples/src/test/resources/META-INF/persistence.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<persistence-unit name="akka-projection-hibernate">
<properties>
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:hibernate-test"/>
<property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:hibernate-test;OPTIMIZE_REUSE_RESULTS=FALSE"/>
<property name="javax.persistence.jdbc.user" value="sa"/>
<property name="javax.persistence.jdbc.password" value=""/>
<!-- field access, no setters -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ object JdbcProjectionDocExample {

lazy val conn = {
Class.forName("org.h2.Driver")
val c = DriverManager.getConnection("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1")
val c = DriverManager.getConnection("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;OPTIMIZE_REUSE_RESULTS=FALSE")
c.setAutoCommit(false)
c
}
Expand Down