From 59fd320a5a965b1b8a7db93c84b294ef0eede046 Mon Sep 17 00:00:00 2001 From: Jay07GIT Date: Tue, 23 Jul 2024 16:54:30 +0530 Subject: [PATCH] removed future await and increased akka http timeout limit --- build/docker/api/application.conf | 1 + modules/api/src/it/resources/application.conf | 1 + modules/api/src/main/resources/application.conf | 1 + modules/api/src/universal/conf/application.conf | 1 + .../docs/src/main/mdoc/operator/config-api.md | 1 + .../repository/MySqlBatchChangeRepository.scala | 17 +++++------------ test/api/functional/application.conf | 1 + test/api/integration/application.conf | 2 +- 8 files changed, 12 insertions(+), 13 deletions(-) diff --git a/build/docker/api/application.conf b/build/docker/api/application.conf index f3d2e8ef2..ae2ec8671 100644 --- a/build/docker/api/application.conf +++ b/build/docker/api/application.conf @@ -350,6 +350,7 @@ akka.http { # The time period within which the TCP binding process must be completed. # Set to `infinite` to disable. bind-timeout = 5s + request-timeout = 60s # Show verbose error messages back to the client verbose-error-messages = on diff --git a/modules/api/src/it/resources/application.conf b/modules/api/src/it/resources/application.conf index dd3b7006e..9a15efdea 100644 --- a/modules/api/src/it/resources/application.conf +++ b/modules/api/src/it/resources/application.conf @@ -347,6 +347,7 @@ akka.http { # The time period within which the TCP binding process must be completed. # Set to `infinite` to disable. bind-timeout = 5s + request-timeout = 60s # Show verbose error messages back to the client verbose-error-messages = on diff --git a/modules/api/src/main/resources/application.conf b/modules/api/src/main/resources/application.conf index c87d4af83..08b230b7d 100644 --- a/modules/api/src/main/resources/application.conf +++ b/modules/api/src/main/resources/application.conf @@ -366,6 +366,7 @@ akka.http { # The time period within which the TCP binding process must be completed. # Set to `infinite` to disable. bind-timeout = 5s + request-timeout = 60s # Show verbose error messages back to the client verbose-error-messages = on diff --git a/modules/api/src/universal/conf/application.conf b/modules/api/src/universal/conf/application.conf index ff70827df..fefbd421a 100644 --- a/modules/api/src/universal/conf/application.conf +++ b/modules/api/src/universal/conf/application.conf @@ -351,6 +351,7 @@ akka.http { # The time period within which the TCP binding process must be completed. # Set to `infinite` to disable. bind-timeout = 5s + request-timeout = 60s # Show verbose error messages back to the client verbose-error-messages = on diff --git a/modules/docs/src/main/mdoc/operator/config-api.md b/modules/docs/src/main/mdoc/operator/config-api.md index 37026de6c..31a77c291 100644 --- a/modules/docs/src/main/mdoc/operator/config-api.md +++ b/modules/docs/src/main/mdoc/operator/config-api.md @@ -990,6 +990,7 @@ dotted-hosts = { # The time period within which the TCP binding process must be completed. # Set to `infinite` to disable. bind-timeout = 5s + request-timeout = 60s # Show verbose error messages back to the client verbose-error-messages = on diff --git a/modules/mysql/src/main/scala/vinyldns/mysql/repository/MySqlBatchChangeRepository.scala b/modules/mysql/src/main/scala/vinyldns/mysql/repository/MySqlBatchChangeRepository.scala index 7dc843401..b121be0f5 100644 --- a/modules/mysql/src/main/scala/vinyldns/mysql/repository/MySqlBatchChangeRepository.scala +++ b/modules/mysql/src/main/scala/vinyldns/mysql/repository/MySqlBatchChangeRepository.scala @@ -29,10 +29,6 @@ import vinyldns.core.protobuf.{BatchChangeProtobufConversions, SingleChangeType} import vinyldns.core.route.Monitored import vinyldns.proto.VinylDNSProto -import scala.concurrent.ExecutionContext.Implicits.global -import scala.concurrent.duration.DurationInt -import scala.concurrent.{Await, Future} - /** * MySqlBatchChangeRepository implements the JDBC queries that support the APIs defined in BatchChangeRepository.scala * BatchChange and SingleChange are stored in RDS as two tables. @@ -185,10 +181,9 @@ class MySqlBatchChangeRepository .apply() batchMeta.copy(changes = changes) } - - def updateSingleChangeStatus(singleChanges: Seq[SingleChange]): Future[Option[BatchChange]] = { - logger.info(s"Updating single change status: ${singleChanges.map(ch => (ch.id, ch.status))}") - Future { + monitor("repo.BatchChangeJDBC.updateSingleChanges") { + IO { + logger.info(s"Updating single change status: ${singleChanges.map(ch => (ch.id, ch.status))}") DB.localTx { implicit s => for { headChange <- singleChanges.headOption @@ -196,12 +191,10 @@ class MySqlBatchChangeRepository _ = UPDATE_SINGLE_CHANGE.batchByName(batchParams: _*).apply() batchChange <- getBatchFromSingleChangeId(headChange.id) } yield batchChange - }}} - - monitor("repo.BatchChangeJDBC.updateSingleChanges") { - IO {Await.result(updateSingleChangeStatus(singleChanges), 50.seconds)} + }} } } + def getSingleChanges(singleChangeIds: List[String]): IO[List[SingleChange]] = if (singleChangeIds.isEmpty) { IO.pure(List()) diff --git a/test/api/functional/application.conf b/test/api/functional/application.conf index e0f35df07..cfb05f9bd 100644 --- a/test/api/functional/application.conf +++ b/test/api/functional/application.conf @@ -301,6 +301,7 @@ akka.http { # The time period within which the TCP binding process must be completed. # Set to `infinite` to disable. bind-timeout = 5s + request-timeout = 60s # Show verbose error messages back to the client verbose-error-messages = on diff --git a/test/api/integration/application.conf b/test/api/integration/application.conf index c09038a85..0434f5692 100644 --- a/test/api/integration/application.conf +++ b/test/api/integration/application.conf @@ -359,7 +359,7 @@ akka.http { # The time period within which the TCP binding process must be completed. # Set to `infinite` to disable. bind-timeout = 5s - + request-timeout = 60s # Show verbose error messages back to the client verbose-error-messages = on }