Quarkus: Error connecting Postgres cluster on AWS

Created on 10 Sep 2020  路  10Comments  路  Source: quarkusio/quarkus

Describe the bug
After upgrading to 1.8.0.Final the Postgres DataSource fails to connect.
It works against a local DB, but fails with the AWS Aurora Postgres instance.
The same AWS Postgres connection from DBeaver is working fine.
With Quarkus 1.5.2.Final it works.

Expected behavior
We expected that the connection is successful

Actual behavior
Cannot connect to the AWS Postgres instance

To Reproduce

  1. Define a datasource with the AWS Postgres instance
  2. Execute quarkus
  3. Make a connection -> Exception

Configuration

quarkus.datasource.jdbc.url=jdbc:postgresql://<aws instance>/<db name>
quarkus.datasource.db-kind=postgresql
quarkus.datasource.username=postgres
quarkus.datasource.password=postgres

Environment (please complete the following information):

  • Output of uname -a or ver: Windows 10
  • Output of java -version: 11
  • GraalVM version (if different from Java):
  • Quarkus version or git rev: 1.8.0.Final
  • Build tool (ie. output of mvnw --version or gradlew --version): mvn 3.6.3

Additional context

2020-09-09 10:23:48,977 ERROR [io.qua.application] (main) Failed to start application (with profile prod): org.flywaydb.core.internal.exception.FlywaySqlException:
Unable to obtain connection from database: The connection attempt failed.
-------------------------------------------------------------------------
SQL State  : 08001
Error Code : 0
Message    : The connection attempt failed.
at org.flywaydb.core.internal.jdbc.JdbcUtils.openConnection(JdbcUtils.java:65)
at org.flywaydb.core.internal.jdbc.JdbcConnectionFactory.<init>(JdbcConnectionFactory.java:80)
at org.flywaydb.core.Flyway.execute(Flyway.java:453)
at org.flywaydb.core.Flyway.migrate(Flyway.java:158)
at io.quarkus.flyway.runtime.FlywayRecorder.doStartActions(FlywayRecorder.java:54)
at io.quarkus.deployment.steps.FlywayProcessor$createBeansAndStartActions-1520831253.deploy_0(FlywayProcessor$createBeansAndStartActions-1520831253.zig:80)
at io.quarkus.deployment.steps.FlywayProcessor$createBeansAndStartActions-1520831253.deploy(FlywayProcessor$createBeansAndStartActions-1520831253.zig:40)
at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:543)
at io.quarkus.runtime.Application.start(Application.java:90)
at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:92)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:61)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:38)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:106)
at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
Caused by: org.postgresql.util.PSQLException: The connection attempt failed.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:315)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:225)
at org.postgresql.Driver.makeConnection(Driver.java:465)
at org.postgresql.Driver.connect(Driver.java:264)
at io.agroal.pool.ConnectionFactory.createConnection(ConnectionFactory.java:200)
at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:419)
at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:401)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at io.agroal.pool.util.PriorityScheduledExecutor.beforeExecute(PriorityScheduledExecutor.java:65)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1126)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.io.EOFException
at org.postgresql.core.PGStream.receiveChar(PGStream.java:443)
at org.postgresql.core.v3.ConnectionFactoryImpl.enableGSSEncrypted(ConnectionFactoryImpl.java:436)
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:144)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:213)
... 12 more
arepersistence kinbug

Most helpful comment

Our team has faced the same problem.
We have Java 11, Postgres 11, Azure cluster, and flyway for migrations. Everything works fine for Quarkus 1.7.0 or 1.7.1, but Flyway fails to connect to datasource when the version is 1.8.0 or 1.8.1.
We've tried to connect to remote DB and to localhost container with Postgres, it works. Something wrong happens during connection to Azure.

All 10 comments

@Teg79 can you downgrade the PostgreSQL JDBC driver version to what it was in 1.5.2.Final?

That would be 42.2.12.

@gsmet Ok we will try

@Teg79 please report back so that we know if there's a bug in the JDBC driver or something else fishy.

@Teg79 any news about this?

@gsmet we replaced the jdbc driver with the 42.2.12 and we have the same error with Quarkus 1.8.0.Final

Hi,

I have the same Error message as Teg79.

I upgraded from 1.6.1-Final to 1.8.1-Final.
After the Update we got the EOF Exception when trying to access our AWS-Aurora-Postgres DB.

It Looks like that with the JDBC Driver Versions: 42.2.16 42.2.15 are responsible for this issue.

with 42.2.14 Here the connection is established.
image

with 42.2.15
image

with 42.2.16
image

Same issue happens on my Azure postgres server, 42.2.16 42.2.15 are not worked, however older version works fine.
Please let me know if there is any updates. Thx

Our team has faced the same problem.
We have Java 11, Postgres 11, Azure cluster, and flyway for migrations. Everything works fine for Quarkus 1.7.0 or 1.7.1, but Flyway fails to connect to datasource when the version is 1.8.0 or 1.8.1.
We've tried to connect to remote DB and to localhost container with Postgres, it works. Something wrong happens during connection to Azure.

Hi guys, I have the same problem (not using Quarkus though). Downgrading to 42.2.14 worked for me. I opened an issue in the postgres driver repository for this

The problem should be fixed with driver version 42.2.18. Please bump the version in one of the next releases.
https://github.com/pgjdbc/pgjdbc/issues/1868

Was this page helpful?
0 / 5 - 0 ratings