mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 01:07:18 +03:00
Avoid using setBinaryStream to not confuse H2 (#5474)
There have been reports of sporadic occurrences of `java.lang.RuntimeException: Lob not found: 49/-2` when running the participant server with H2. It seems like using `setBinaryStream` triggers H2 to go through the BLOB machinery. Since this issue is not easily reproducible, it seems like an altogether better solution to switch to using `setBytes`. Offsets aren't that large anyway, so going directly for byte array should be fine. Better than a broken query anway. CHANGELOG_BEGIN CHANGELOG_END
This commit is contained in:
parent
26f073bda7
commit
a9755cb852
@ -3,7 +3,6 @@
|
||||
|
||||
package com.daml.platform.store
|
||||
|
||||
import java.io.InputStream
|
||||
import java.sql.PreparedStatement
|
||||
import java.time.Instant
|
||||
import java.util.Date
|
||||
@ -152,14 +151,14 @@ object Conversions {
|
||||
|
||||
implicit def offsetToStatement: ToStatement[Offset] = new ToStatement[Offset] {
|
||||
override def set(s: PreparedStatement, index: Int, v: Offset): Unit =
|
||||
s.setBinaryStream(index, v.toInputStream)
|
||||
s.setBytes(index, v.toByteArray)
|
||||
}
|
||||
|
||||
def offset(name: String): RowParser[Offset] =
|
||||
SqlParser.get[InputStream](name).map(Offset.fromInputStream)
|
||||
SqlParser.get[Array[Byte]](name).map(Offset.fromByteArray)
|
||||
|
||||
implicit def columnToOffset(implicit c: Column[InputStream]): Column[Offset] =
|
||||
Column.nonNull((value: Any, meta) => c(value, meta).toEither.map(Offset.fromInputStream))
|
||||
implicit def columnToOffset(implicit c: Column[Array[Byte]]): Column[Offset] =
|
||||
Column.nonNull((value: Any, meta) => c(value, meta).toEither.map(Offset.fromByteArray))
|
||||
|
||||
// Instant
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user