Skip to content
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

OpenGauss Driver failed to connect shardingsphere #34925

Open
jzs1997 opened this issue Mar 7, 2025 · 5 comments
Open

OpenGauss Driver failed to connect shardingsphere #34925

jzs1997 opened this issue Mar 7, 2025 · 5 comments

Comments

@jzs1997
Copy link

jzs1997 commented Mar 7, 2025

Bug Report

Which version of ShardingSphere did you use?

Compiled from source code, without any modification
openGauss version: 7.0.0 compiled from latest source code
openGauss-JDBC-driver version: opengauss-jdbc-6.0.0

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

ShardingSphere-Proxy

Expected behavior

Connection Built Successfully

Actual behavior

Failed to build connection

When I tried to connect to shardingsphere via openGauss-jdbc-driver, I got this error:

Exception in thread "main" org.opengauss.util.PSQLException: Something unusual has occured to cause the driver to fail. Please report this exception.
	at org.opengauss.Driver.connect(Driver.java:337)
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:251)
	at Test1.buildConnection(Test1.java:13)
	at Test1.<init>(Test1.java:8)
	at Main.main(Main.java:6)
Caused by: java.lang.IllegalArgumentException: No enum constant org.opengauss.util.CompatibilityEnum.
	at java.base/java.lang.Enum.valueOf(Enum.java:240)
	at org.opengauss.util.CompatibilityEnum.valueOf(CompatibilityEnum.java:3)
	at org.opengauss.jdbc.PgDatabase.setDolphin(PgDatabase.java:48)
	at org.opengauss.jdbc.PgConnection.<init>(PgConnection.java:332)
	at org.opengauss.Driver.makeConnection(Driver.java:568)
	at org.opengauss.Driver.connect(Driver.java:317)
	... 5 more

Basically dolphin is an extension of openGauss which is not installed by default. And in openGauss-jdbc-driver, it will decide where to use dolphin:

public class PgDatabase {
    private PgConnection connection;
    private boolean isDolphin;
    private boolean isDec;

    public PgDatabase(PgConnection connection) {
        this.connection = connection;
    }

    public boolean isDolphin() {
        return this.isDolphin;
    }

    public boolean isDec() {
        return this.isDec;
    }

    public void setDolphin(Properties info) throws SQLException {
        String extensionDolphin = this.getDolphin("select count(1) from pg_extension where extname = 'dolphin';");
        int dolphinNum = Integer.parseInt(extensionDolphin);
        String compatibility = this.getDolphin("show dolphin.b_compatibility_mode;");
        CompatibilityEnum compatibilityEnum = CompatibilityEnum.valueOf(compatibility.toUpperCase(Locale.ROOT));
        if (dolphinNum > 0 && CompatibilityEnum.ON.equals(compatibilityEnum)) {
            this.isDolphin = true;
            String bitOutput = PGProperty.BIT_OUTPUT.get(info);
            if (bitOutput == null) {
                bitOutput = this.getDolphin("show dolphin.bit_output;");
            } else {
                this.updateBitOutput(bitOutput);
            }

            if (BitOutputEnum.DEC.equals(BitOutputEnum.valueOf(bitOutput.toUpperCase(Locale.ROOT)))) {
                this.isDec = true;
            }
        } else {
            this.isDolphin = false;
        }

    }

Basically, if the dolphinNum larger than 0 it will think it needs to set dolphin, but I do not have dolphin which means select count(1) from pg_extension where extname = 'dolphin'; will return 0 and I checked this in my database and shardingsphere and the values returned are all 0.

Image

Image

I am new to this. I tried to debug this but got pretty confused. Hope that I could at least got some hint on which module I should check.

Thanks!

Btw, I can connect to shardingsphere with gsql

@linghengqian
Copy link
Member

  • Actually, the master branch of shardingsphere is using the JDBC Driver of org.opengauss:opengauss-jdbc:3.1.0-og to do integration testing on the Docker Image of enmotech/opengauss-lite:5.1.0. Can you use org.opengauss:opengauss-jdbc:3.1.0-og for testing? Or you try to raise a PR to update https://github.com/apache/shardingsphere/blob/master/pom.xml#L128 to org.opengauss:opengauss-jdbc:6.0.0-og?
  • Do you mean org.opengauss:opengauss-jdbc:6.0.0-og or org.opengauss:opengauss-jdbc:6.0.0? These two JDBC Drivers use different java packages, and ShardingSphere only tests the *-og versions.

openGauss version: 7.0.0 compiled from latest source code

  • Can you point out what Docker Image you are using? Is it on Docker Hub or GHCR?

@jzs1997
Copy link
Author

jzs1997 commented Mar 8, 2025

  • Actually, the master branch of shardingsphere is using the JDBC Driver of org.opengauss:opengauss-jdbc:3.1.0-og to do integration testing on the Docker Image of enmotech/opengauss-lite:5.1.0. Can you use org.opengauss:opengauss-jdbc:3.1.0-og for testing? Or you try to raise a PR to update https://github.com/apache/shardingsphere/blob/master/pom.xml#L128 to org.opengauss:opengauss-jdbc:6.0.0-og?
  • Do you mean org.opengauss:opengauss-jdbc:6.0.0-og or org.opengauss:opengauss-jdbc:6.0.0? These two JDBC Drivers use different java packages, and ShardingSphere only tests the *-og versions.

openGauss version: 7.0.0 compiled from latest source code

  • Can you point out what Docker Image you are using? Is it on Docker Hub or GHCR?

Hi hengqiang
I am not using a Docker Image, I deployed shardingsphere on openEuler 20, downloaded the code of shardingsphere on github and compile it with maven. And for the openGauss. I download the code from gitee and compile the code.
I think I am using org.opengauss:opengauss-jdbc:6.0.0-og.
I will try org.opengauss:opengauss-jdbc:3.1.0-og
Now my solution is comment the setDolphin part code in jdbc. And now I can connect to shardingsphere with jdbc, but i think this is not a good solution.

 uname -a
Linux localhost.localdomain 4.19.90-2003.4.0.0036.oe1.aarch64 #1 SMP Mon Mar 23 19:06:43 UTC 2020 aarch64 aarch64 aarch64 GNU/Linux

 cat /etc/os-release 
NAME="openEuler"
VERSION="20.03 (LTS)"
ID="openEuler"
VERSION_ID="20.03"
PRETTY_NAME="openEuler 20.03 (LTS)"
ANSI_COLOR="0;31"

@linghengqian
Copy link
Member

linghengqian commented Mar 8, 2025

Compiled from source code, without any modification

  • To be honest, I don't understand how you compiled it. The JAR of org.opengauss:opengauss-jdbc:3.1.0-og is in the apache-shardingsphere-5.5.3-SNAPSHOT-shardingsphere-proxy-bin.tar.gz or Docker Image of ShardingSphere Proxy by default.

@Y-sir
Copy link

Y-sir commented Mar 10, 2025

  • Actually, the master branch of shardingsphere is using the JDBC Driver of org.opengauss:opengauss-jdbc:3.1.0-og to do integration testing on the Docker Image of enmotech/opengauss-lite:5.1.0. Can you use org.opengauss:opengauss-jdbc:3.1.0-og for testing? Or you try to raise a PR to update https://github.com/apache/shardingsphere/blob/master/pom.xml#L128 to org.opengauss:opengauss-jdbc:6.0.0-og?
  • Do you mean org.opengauss:opengauss-jdbc:6.0.0-og or org.opengauss:opengauss-jdbc:6.0.0? These two JDBC Drivers use different java packages, and ShardingSphere only tests the *-og versions.

openGauss version: 7.0.0 compiled from latest source code

  • Can you point out what Docker Image you are using? Is it on Docker Hub or GHCR?

Hi hengqiang I am not using a Docker Image, I deployed shardingsphere on openEuler 20, downloaded the code of shardingsphere on github and compile it with maven. And for the openGauss. I download the code from gitee and compile the code. I think I am using org.opengauss:opengauss-jdbc:6.0.0-og. I will try org.opengauss:opengauss-jdbc:3.1.0-og Now my solution is comment the setDolphin part code in jdbc. And now I can connect to shardingsphere with jdbc, but i think this is not a good solution.

 uname -a
Linux localhost.localdomain 4.19.90-2003.4.0.0036.oe1.aarch64 #1 SMP Mon Mar 23 19:06:43 UTC 2020 aarch64 aarch64 aarch64 GNU/Linux

 cat /etc/os-release 
NAME="openEuler"
VERSION="20.03 (LTS)"
ID="openEuler"
VERSION_ID="20.03"
PRETTY_NAME="openEuler 20.03 (LTS)"
ANSI_COLOR="0;31"

@jzs1997 Hello, I am also facing this problem. You said that your solution is to comment out the setDolphin part of the code in jdbc, so that you can use jdbc to connect to shardingsphere. Which part of the code did you comment out?

@linghengqian
Copy link
Member

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

No branches or pull requests

3 participants