Decode DAML-LF retrieved from the database in the server thread pool (#4655)

This relieves the database thread pool from work it's not supposed to
do.

CHANGELOG_BEGIN
CHANGELOG_END
This commit is contained in:
Stefano Baghino 2020-02-21 17:39:18 +01:00 committed by GitHub
parent 4a8c5cf24e
commit 1b23be6cc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1503,14 +1503,16 @@ private class JdbcLedgerDao(
} }
override def getLfArchive(packageId: PackageId): Future[Option[Archive]] = override def getLfArchive(packageId: PackageId): Future[Option[Archive]] =
dbDispatcher.executeSql("load_archive", Some(s"pkg id: $packageId")) { implicit conn => dbDispatcher
SQL_SELECT_PACKAGE .executeSql("load_archive", Some(s"pkg id: $packageId")) { implicit conn =>
.on( SQL_SELECT_PACKAGE
"package_id" -> packageId .on(
) "package_id" -> packageId
.as[Option[Array[Byte]]](SqlParser.byteArray("package").singleOpt) )
.map(data => Archive.parseFrom(Decode.damlLfCodedInputStreamFromBytes(data))) .as[Option[Array[Byte]]](SqlParser.byteArray("package").singleOpt)
} }
.map(_.map(data => Archive.parseFrom(Decode.damlLfCodedInputStreamFromBytes(data))))(
executionContext)
private val SQL_INSERT_PACKAGE_ENTRY_ACCEPT = private val SQL_INSERT_PACKAGE_ENTRY_ACCEPT =
SQL("""insert into package_entries(ledger_offset, recorded_at, submission_id, typ) SQL("""insert into package_entries(ledger_offset, recorded_at, submission_id, typ)