From 21314a70463a693f1f19380560fdf2049faf96c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Diego=20L=C3=B3pez=20V?= Date: Wed, 25 Oct 2023 19:17:26 -0400 Subject: [PATCH] enable use layer 7 proxy for reactive pg client --- .../runtime/DataSourceReactivePostgreSQLConfig.java | 10 ++++++++++ .../reactive/pg/client/runtime/PgPoolRecorder.java | 2 ++ 2 files changed, 12 insertions(+) diff --git a/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/DataSourceReactivePostgreSQLConfig.java b/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/DataSourceReactivePostgreSQLConfig.java index 681e4d0e6b3af..46c5d640e719c 100644 --- a/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/DataSourceReactivePostgreSQLConfig.java +++ b/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/DataSourceReactivePostgreSQLConfig.java @@ -5,6 +5,7 @@ import io.quarkus.runtime.annotations.ConfigDocDefault; import io.quarkus.runtime.annotations.ConfigGroup; +import io.smallrye.config.WithDefault; import io.vertx.pgclient.SslMode; @ConfigGroup @@ -23,4 +24,13 @@ public interface DataSourceReactivePostgreSQLConfig { */ @ConfigDocDefault("disable") Optional sslMode(); + + /** + * Level 7 proxies can load balance queries on several connections to the actual database. + * When it happens, the client can be confused by the lack of session affinity and unwanted errors can happen like + * ERROR: unnamed prepared statement does not exist (26000). + * See Using a level 7 proxy + */ + @WithDefault("false") + boolean useLayer7Proxy(); } diff --git a/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java b/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java index 053c68a56708f..18149f6e67b1a 100644 --- a/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java +++ b/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/PgPoolRecorder.java @@ -207,6 +207,8 @@ private List toPgConnectOptions(String dataSourceName, DataSou } } + pgConnectOptions.setUseLayer7Proxy(dataSourceReactivePostgreSQLConfig.useLayer7Proxy()); + pgConnectOptions.setTrustAll(dataSourceReactiveRuntimeConfig.trustAll()); configurePemTrustOptions(pgConnectOptions, dataSourceReactiveRuntimeConfig.trustCertificatePem());