quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.57k stars 2.63k forks source link

Error connecting Postgres cluster on AWS #12022

Closed Teg79 closed 1 month ago

Teg79 commented 4 years ago

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):

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
gsmet commented 4 years ago

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

That would be 42.2.12.

Teg79 commented 4 years ago

@gsmet Ok we will try

gsmet commented 4 years ago

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

gsmet commented 4 years ago

@Teg79 any news about this?

Teg79 commented 3 years ago

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

Kranas2142 commented 3 years ago

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

Xwang0515 commented 3 years ago

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

OleKsimov commented 3 years ago

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.

fongie commented 3 years ago

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

wswoboda commented 3 years ago

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

yrodiere commented 1 month ago

From what I can see we now use Postgresql JDBC version 42.7.3, so this problem should be fixed.

I'll close this issue, feel free to comment if it wasn't fixed.

SuryaRK2906 commented 1 month ago

Still am facing same issue while connecting with version Postgresql 42.7.3 ( AWS RDS Aurora Postgresql)

sevmelo commented 3 weeks ago

I'm also getting similar issue while connecting with version Postgresql 42.7.3 ( AWS RDS Aurora Postgresql). Any ideas on how to solve?

yrodiere commented 2 weeks ago

This is a very old issue on an unmaintained version of Quarkus.

If you're having problems connection to PostgreSQL on AWS while using Quarkus 3.8+, please open an issue with a reproducer (simple project that demonstrates the issue).