From d03e8e498a3356174e8de9a3dfd46938add2abc4 Mon Sep 17 00:00:00 2001 From: Tristan Vuong <85768771+tristanvuong2021@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:10:12 -0800 Subject: [PATCH] revert: Postgres Connection Pool (#292) Revert #289 --- MODULE.bazel | 1 - imports/java/io/r2dbc/pool/BUILD.bazel | 6 --- maven_install.json | 43 +------------------ .../measurement/gcloud/postgres/BUILD.bazel | 1 - .../postgres/PostgresConnectionFactories.kt | 35 +++++---------- .../gcloud/postgres/PostgresFlags.kt | 38 ---------------- 6 files changed, 13 insertions(+), 111 deletions(-) delete mode 100644 imports/java/io/r2dbc/pool/BUILD.bazel diff --git a/MODULE.bazel b/MODULE.bazel index f3a9f789f..5a26df9f6 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -239,7 +239,6 @@ maven.install( "org.postgresql:postgresql:42.7.0", "org.postgresql:r2dbc-postgresql:1.0.4.RELEASE", "io.r2dbc:r2dbc-spi:1.0.0.RELEASE", - "io.r2dbc:r2dbc-pool:1.0.0.RELEASE", # Liquibase. "org.yaml:snakeyaml:2.2", diff --git a/imports/java/io/r2dbc/pool/BUILD.bazel b/imports/java/io/r2dbc/pool/BUILD.bazel deleted file mode 100644 index 6d24fcab6..000000000 --- a/imports/java/io/r2dbc/pool/BUILD.bazel +++ /dev/null @@ -1,6 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -alias( - name = "pool", - actual = "@maven//:io_r2dbc_r2dbc_pool", -) diff --git a/maven_install.json b/maven_install.json index a789ba543..d95814eb7 100755 --- a/maven_install.json +++ b/maven_install.json @@ -1,7 +1,7 @@ { "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL", - "__INPUT_ARTIFACTS_HASH": 838604840, - "__RESOLVED_ARTIFACTS_HASH": -1724946481, + "__INPUT_ARTIFACTS_HASH": 1541805035, + "__RESOLVED_ARTIFACTS_HASH": 81502917, "artifacts": { "com.adobe.testing:s3mock": { "shasums": { @@ -1296,13 +1296,6 @@ }, "version": "0.27.0" }, - "io.projectreactor.addons:reactor-pool": { - "shasums": { - "jar": "1ef7e46c3ab451684488879ffca6c2bb0039e29f02af60d780fe7d481bdffea1", - "sources": "e7ace37b6bf9cf1d5b11e1d0be1e92f75d278b594a691a1e36613391f3b646a1" - }, - "version": "1.0.8" - }, "io.projectreactor.netty:reactor-netty-core": { "shasums": { "jar": "9dd0c5ac8216586a3cc41a7c4ff6b1482e3f5ede61798c2d9b6a13c34c199994", @@ -1317,13 +1310,6 @@ }, "version": "3.6.9" }, - "io.r2dbc:r2dbc-pool": { - "shasums": { - "jar": "be1ad2fd95629c70dfcf384be1eb4bfc1723d90d6a0d2e4227d02f3b7ab0885a", - "sources": "aceb2ace85124594de15c367e7dc769586e02cc169e546cff4dc623b9831a060" - }, - "version": "1.0.0.RELEASE" - }, "io.r2dbc:r2dbc-spi": { "shasums": { "jar": "a5846c59fea336431a4ae72ca14edbf5299b78486fa308eafb383f4ae0ea74e5", @@ -3508,9 +3494,6 @@ "io.opentelemetry:opentelemetry-api-incubator", "io.opentelemetry:opentelemetry-sdk" ], - "io.projectreactor.addons:reactor-pool": [ - "io.projectreactor:reactor-core" - ], "io.projectreactor.netty:reactor-netty-core": [ "io.netty:netty-handler", "io.netty:netty-handler-proxy", @@ -3522,11 +3505,6 @@ "io.projectreactor:reactor-core": [ "org.reactivestreams:reactive-streams" ], - "io.r2dbc:r2dbc-pool": [ - "io.projectreactor.addons:reactor-pool", - "io.projectreactor:reactor-core", - "io.r2dbc:r2dbc-spi" - ], "io.r2dbc:r2dbc-spi": [ "org.reactivestreams:reactive-streams" ], @@ -5955,11 +5933,6 @@ "io.perfmark:perfmark-api": [ "io.perfmark" ], - "io.projectreactor.addons:reactor-pool": [ - "reactor.pool", - "reactor.pool.decorators", - "reactor.pool.introspection" - ], "io.projectreactor.netty:reactor-netty-core": [ "reactor.netty", "reactor.netty.channel", @@ -5988,9 +5961,6 @@ "reactor.util.function", "reactor.util.retry" ], - "io.r2dbc:r2dbc-pool": [ - "io.r2dbc.pool" - ], "io.r2dbc:r2dbc-spi": [ "io.r2dbc.spi" ], @@ -9129,14 +9099,10 @@ "io.opentelemetry:opentelemetry-sdk:jar:sources", "io.perfmark:perfmark-api", "io.perfmark:perfmark-api:jar:sources", - "io.projectreactor.addons:reactor-pool", - "io.projectreactor.addons:reactor-pool:jar:sources", "io.projectreactor.netty:reactor-netty-core", "io.projectreactor.netty:reactor-netty-core:jar:sources", "io.projectreactor:reactor-core", "io.projectreactor:reactor-core:jar:sources", - "io.r2dbc:r2dbc-pool", - "io.r2dbc:r2dbc-pool:jar:sources", "io.r2dbc:r2dbc-spi", "io.r2dbc:r2dbc-spi:jar:sources", "jakarta.activation:jakarta.activation-api", @@ -9764,11 +9730,6 @@ "reactor.core.scheduler.ReactorBlockHoundIntegration" ] }, - "io.r2dbc:r2dbc-pool": { - "io.r2dbc.spi.ConnectionFactoryProvider": [ - "io.r2dbc.pool.PoolingConnectionFactoryProvider" - ] - }, "org.apache.tomcat.embed:tomcat-embed-el": { "jakarta.el.ExpressionFactory": [ "org.apache.el.ExpressionFactoryImpl" diff --git a/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/BUILD.bazel index acf5c4665..82678eb64 100644 --- a/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/BUILD.bazel @@ -15,7 +15,6 @@ kt_jvm_library( srcs = ["PostgresConnectionFactories.kt"], deps = [ "//imports/java/com/google/cloud/sql:r2dbc-core", - "//imports/java/io/r2dbc/pool", "//imports/java/org/postgresql:r2dbc", "//src/main/kotlin/org/wfanet/measurement/gcloud/postgres:flags", ], diff --git a/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/PostgresConnectionFactories.kt b/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/PostgresConnectionFactories.kt index febe74ba2..8bfd6d519 100644 --- a/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/PostgresConnectionFactories.kt +++ b/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/PostgresConnectionFactories.kt @@ -15,8 +15,6 @@ package org.wfanet.measurement.gcloud.postgres import com.google.cloud.sql.core.GcpConnectionFactoryProvider -import io.r2dbc.pool.ConnectionPool -import io.r2dbc.pool.ConnectionPoolConfiguration import io.r2dbc.spi.ConnectionFactories import io.r2dbc.spi.ConnectionFactory import io.r2dbc.spi.ConnectionFactoryOptions @@ -24,28 +22,17 @@ import io.r2dbc.spi.ConnectionFactoryOptions object PostgresConnectionFactories { @JvmStatic fun buildConnectionFactory(flags: PostgresFlags): ConnectionFactory { - val connectionFactory = - ConnectionFactories.get( - ConnectionFactoryOptions.builder() - .option(ConnectionFactoryOptions.DRIVER, "gcp") - .option(ConnectionFactoryOptions.PROTOCOL, "postgresql") - .option(ConnectionFactoryOptions.USER, flags.user) - // a non-empty password is required, but the value doesn't matter - .option(ConnectionFactoryOptions.PASSWORD, "UNUSED") - .option(ConnectionFactoryOptions.DATABASE, flags.database) - .option(ConnectionFactoryOptions.HOST, flags.cloudSqlInstance) - .option(ConnectionFactoryOptions.STATEMENT_TIMEOUT, flags.statementTimeout) - .option(GcpConnectionFactoryProvider.ENABLE_IAM_AUTH, true) - .build() - ) - - val configuration: ConnectionPoolConfiguration = - ConnectionPoolConfiguration.builder(connectionFactory) - .maxIdleTime(flags.maxIdleTime) - .maxSize(flags.maxPoolSize) - .acquireRetry(flags.acquireRetry) + return ConnectionFactories.get( + ConnectionFactoryOptions.builder() + .option(ConnectionFactoryOptions.DRIVER, "gcp") + .option(ConnectionFactoryOptions.PROTOCOL, "postgresql") + .option(ConnectionFactoryOptions.USER, flags.user) + // a non-empty password is required, but the value doesn't matter + .option(ConnectionFactoryOptions.PASSWORD, "UNUSED") + .option(ConnectionFactoryOptions.DATABASE, flags.database) + .option(ConnectionFactoryOptions.HOST, flags.cloudSqlInstance) + .option(GcpConnectionFactoryProvider.ENABLE_IAM_AUTH, true) .build() - - return ConnectionPool(configuration) + ) } } diff --git a/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/PostgresFlags.kt b/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/PostgresFlags.kt index 094ac72ad..56797bdf4 100644 --- a/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/PostgresFlags.kt +++ b/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/PostgresFlags.kt @@ -14,8 +14,6 @@ package org.wfanet.measurement.gcloud.postgres -import java.time.Duration -import kotlin.properties.Delegates import picocli.CommandLine /** Common command-line flags for connecting to a single Postgres database. */ @@ -43,40 +41,4 @@ class PostgresFlags { ) lateinit var user: String private set - - @CommandLine.Option( - names = ["--statement-timeout"], - description = ["Statement timeout duration."], - required = false, - defaultValue = "120s", - ) - lateinit var statementTimeout: Duration - private set - - @CommandLine.Option( - names = ["--max-idle-time"], - description = ["Maximum duration a connection can be idle before being closed."], - required = false, - defaultValue = "5m", - ) - lateinit var maxIdleTime: Duration - private set - - @set:CommandLine.Option( - names = ["--max-connection-pool-size"], - description = ["Maximum number of connections in pool."], - required = false, - defaultValue = "16", - ) - var maxPoolSize by Delegates.notNull() - private set - - @set:CommandLine.Option( - names = ["--acquire-retry"], - description = ["Maximum number of retries when acquiring a connection from the pool."], - required = false, - defaultValue = "10", - ) - var acquireRetry by Delegates.notNull() - private set }