This is an automated email from the ASF dual-hosted git repository.
pjfanning pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko-persistence-jdbc.git
The following commit(s) were added to refs/heads/main by this push:
new 19cd651f Use the configured schema in the H2 durable state sequence
lookup (#608)
19cd651f is described below
commit 19cd651f78f3f3b527011fae6e041b7e7325f580
Author: PJ Fanning <[email protected]>
AuthorDate: Mon Sep 7 08:22:51 2026 +0100
Use the configured schema in the H2 durable state sequence lookup (#608)
Motivation:
`H2SequenceNextValUpdater` looks up the column default that provides the
next
global offset with `TABLE_SCHEMA = 'PUBLIC'` hard coded, so it finds
nothing when
`jdbc-durable-state-store.tables.durable_state.schemaName` points at another
schema. `upsertObject` then fails with `NoSuchElementException: empty.head`.
`H2DurableStateStorePluginSchemaSpec` covers exactly that configuration and
fails when it is run on its own. It only passes as part of the full core
test
run because an earlier suite leaves a `durable_state` table behind in the
`PUBLIC` schema of the shared H2 in-memory database.
Modification:
Use the configured schema name, falling back to `PUBLIC`, and compare it
case
insensitively, because H2 upper cases unquoted identifiers unless the
database
was created with `DATABASE_TO_UPPER=false`.
Result:
Durable state works on H2 with a schema other than `PUBLIC`.
Tests:
- sbt "core/testOnly
org.apache.pekko.persistence.jdbc.state.scaladsl.H2DurableStateStorePluginSchemaSpec"
- passed; fails on main with NoSuchElementException: empty.head
- sbt "core/testOnly *DurableState*" - passed
- scalafmt --mode diff-ref=upstream/main - no changes
References:
None - found while making the durable state store close its connection pool
---
.../apache/pekko/persistence/jdbc/state/SequenceNextValUpdater.scala | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git
a/core/src/main/scala/org/apache/pekko/persistence/jdbc/state/SequenceNextValUpdater.scala
b/core/src/main/scala/org/apache/pekko/persistence/jdbc/state/SequenceNextValUpdater.scala
index 95213907..2de38f25 100644
---
a/core/src/main/scala/org/apache/pekko/persistence/jdbc/state/SequenceNextValUpdater.scala
+++
b/core/src/main/scala/org/apache/pekko/persistence/jdbc/state/SequenceNextValUpdater.scala
@@ -39,11 +39,14 @@ import slick.sql.SqlStreamingAction
// H2 dependent (based on https://www.h2database.com/html/systemtables.html)
def getSequenceNextValueExpr() = {
+ // H2 stores unquoted identifiers upper case unless the database is
created with DATABASE_TO_UPPER=false,
+ // so the configured schema name is compared case insensitively
+ val schemaName = durableStateTableCfg.schemaName.getOrElse("PUBLIC")
sql"""SELECT COLUMN_DEFAULT
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = '#${durableStateTableCfg.tableName}'
AND COLUMN_NAME =
'#${durableStateTableCfg.columnNames.globalOffset}'
- AND TABLE_SCHEMA = 'PUBLIC'""".as[String]
+ AND UPPER(TABLE_SCHEMA) = UPPER('#$schemaName')""".as[String]
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]