Skip to content

chore: use Java 21 for building pgjdbc by default #3612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2025

Conversation

vlsi
Copy link
Member

@vlsi vlsi commented Apr 29, 2025

Note: the resulting binaries still target Java 8, so the change should not be use-visible.

However, we would use a newer toolset which should result in fewer bugs in the generated binaries.

@vlsi
Copy link
Member Author

vlsi commented Apr 29, 2025

I think we should be good to go for Java 21 for spawning the build. Looks like the CI succeeds, so we are good to go.
Any objections on merging this?

@sehrope
Copy link
Member

sehrope commented Apr 29, 2025

LGTM.

For anybody else reading this, we're going from 17 to 21 (which like 17 is an LTS release) for the build itself. Testing etc still happens on multiple JDK versions including 8 and none of this changes any of that.

@vlsi vlsi force-pushed the build_jdk21 branch 2 times, most recently from 18fa7bd to f68a77d Compare April 29, 2025 14:11
appveyor.yml Outdated
Comment on lines 55 to 80
- psql -U postgres -c "CREATE LANGUAGE plpgsql" test
- psql -U postgres -c "CREATE EXTENSION hstore" test
- psql -U postgres -c "CREATE EXTENSION sslinfo" postgres
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have to change anything for this when we're only updating the JDK version?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait, is this because appveyor was completely broken before and now it might actually work?

@vlsi
Copy link
Member Author

vlsi commented Apr 29, 2025

interestingly, ChatGPT figured out that wal_keep_segments configuration option was deprecated since PG 13, so it could be a reason for the failure when starting PostgreSQL 15/16 at AppVeyor: https://chatgpt.com/share/6810e0e1-9038-800f-acde-02e785eb28d1

@sehrope
Copy link
Member

sehrope commented Apr 29, 2025

That's awesome. Looks like it's mostly working too.

I see some errors for the auth test. Feels like this appveyor stuff has been broken forever that I don't think whatever we did to the GHA environment to work was ever done there too (the explicit stuff in HBA to test the different auth types). If it's going to be annoying to get it to work, maybe just disable those tests on appveyor.

@vlsi
Copy link
Member Author

vlsi commented Apr 29, 2025

There are still two failures, and I don't understand why the tests expect certain output values:

Here we fail to authenticate. Did we get the user right? Should it be pre-created when creating the DB? Should the DB be preconfigured somehow? I'm a bit lost here.

FAILURE   0.2sec, org.postgresql.test.util.PasswordUtilTest > mD5()
    java.lang.RuntimeException: Failed to authenticate using supplied user and password
        at org.postgresql.test.util.PasswordUtilTest.assertValidUsernamePassword(PasswordUtilTest.java:44)
        at org.postgresql.test.util.PasswordUtilTest.testUserPassword(PasswordUtilTest.java:79)
        at org.postgresql.test.util.PasswordUtilTest.testUserPassword(PasswordUtilTest.java:110)
        at org.postgresql.test.util.PasswordUtilTest.testUserPassword(PasswordUtilTest.java:125)
        at org.postgresql.test.util.PasswordUtilTest.mD5(PasswordUtilTest.java:152)
        Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "test_password_md5cb54c42fe0974f50"
            at app//org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:745)
            at app//org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:234)
            at app//org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:289)
            at app//org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:57)
            at app//org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:277)
            at app//org.postgresql.Driver.makeConnection(Driver.java:448)
            at app//org.postgresql.Driver.connect(Driver.java:298)
            at platform/java.sql@21.0.2/java.sql.DriverManager.getConnection(DriverManager.java:683)
            at platform/java.sql@21.0.2/java.sql.DriverManager.getConnection(DriverManager.java:191)
            at app//org.postgresql.test.TestUtil.openDB(TestUtil.java:401)
            at app//org.postgresql.test.util.PasswordUtilTest.assertValidUsernamePassword(PasswordUtilTest.java:40)
            ... 4 more

We get "The authentication type should match ==> expected: <MD5_PASSWORD> but was: ", however, it is hard to understand why exactly something should be MD5.

FAILURE   0.2sec, org.postgresql.test.plugin.AuthenticationPluginTest > authPluginMD5()
    org.opentest4j.AssertionFailedError: The authentication type should match ==> expected: <MD5_PASSWORD> but was: <SASL>
        at app//org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
        at app//org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
        at app//org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197)
        at app//org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:182)
        at app//org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1156)
        at app//org.postgresql.test.plugin.AuthenticationPluginTest.lambda$testAuthPlugin$0(AuthenticationPluginTest.java:55)
        at app//org.postgresql.test.plugin.AuthenticationPluginTest$DummyAuthenticationPlugin.getPassword(AuthenticationPluginTest.java:38)
        at app//org.postgresql.core.v3.AuthenticationPluginManager.withPassword(AuthenticationPluginManager.java:78)
        at app//org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:886)
        at app//org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:234)
        at app//org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:289)
        at app//org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:57)
        at app//org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:277)
        at app//org.postgresql.Driver.makeConnection(Driver.java:448)
        at app//org.postgresql.Driver.connect(Driver.java:298)
        at platform/java.sql@21.0.2/java.sql.DriverManager.getConnection(DriverManager.java:683)
        at platform/java.sql@21.0.2/java.sql.DriverManager.getConnection(DriverManager.java:191)
        at app//org.postgresql.test.TestUtil.openDB(TestUtil.java:401)
        at app//org.postgresql.test.plugin.AuthenticationPluginTest.testAuthPlugin(AuthenticationPluginTest.java:57)
        at app//org.postgresql.test.plugin.AuthenticationPluginTest.authPluginMD5(AuthenticationPluginTest.java:67)

@davecramer
Copy link
Member

There are still two failures, and I don't understand why the tests expect certain output values:

Here we fail to authenticate. Did we get the user right? Should it be pre-created when creating the DB? Should the DB be preconfigured somehow? I'm a bit lost here.
Yes postgresql.conf has to have #password_encryption = scram-sha-256 # scram-sha-256 or md5 set to md5 for this to work.

by default the password_encryption will be set to scram-sha-256. I'd vote for dumping the md5 test

Dave

@vlsi vlsi force-pushed the build_jdk21 branch 6 times, most recently from f28858e to 743dac2 Compare April 30, 2025 09:10
@@ -36,7 +36,6 @@ main () {

# Customize pg_hba.conf
local pg_hba="/home/certdir/pg_hba.conf"
sed -i 's/127.0.0.1\/32/0.0.0.0\/0/g' "${pg_hba}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what was the reason to have 127.0.0.1/32 in the source pg_hba.conf file and replace it with 0.0.0.0/0 later, so I replaced the value with the base pg_hba.conf file so we don't need to replace them. At the same time, I replaced 0.0.0.0/0 with all to support both ipv4 and ipv6 ips.

@vlsi vlsi force-pushed the build_jdk21 branch 10 times, most recently from 453e9ff to eb72cc3 Compare April 30, 2025 12:01
@davecramer
Copy link
Member

I commend your persistence here

@vlsi
Copy link
Member Author

vlsi commented Apr 30, 2025

Even though I managed to get both PG 11 and 16 tested at AppVeyor, I leave just 16 as each test run takes ~20 minutes, so waiting both is way too long

Note: the resulting binaries still target Java 8, so the change should not
be use-visible.

However, we would use a newer toolset which should result in fewer bugs in
the generated binaries.

wal_keep_segments is deprecated since PostgreSQL 13, so remove it from appveyor.yaml
@vlsi vlsi added the chore label May 1, 2025
@vlsi vlsi merged commit 4d273f1 into pgjdbc:master May 1, 2025
18 of 19 checks passed
@davecramer
Copy link
Member

Good work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants