Skip to content

[Bug] [Docker] opengauss-jdbc in image lib/ hijacks org.postgresql.Driver — all PostgreSQL connections fail with "Protocol error. Session setup failed" #11510

Description

@SEZ9

Search before asking

  • I had searched in the issues and found no similar issues.

What happened

The official Docker image apache/seatunnel:latest (2.3.13) ships opengauss-jdbc-5.1.0.jar in /opt/seatunnel/lib/. This jar contains its own copy of the org.postgresql.Driver class (openGauss's JDBC driver is a fork of pgJDBC that keeps the original package names). Because both jars sit on the global classpath, the openGauss copy can hijack the class resolution for the real PostgreSQL driver (postgresql-42.4.3.jar, also in lib/).

Result: every PostgreSQL connection through the Jdbc connector fails against a standard PostgreSQL 14 server using scram-sha-256 auth:

Caused by: org.postgresql.util.PSQLException: Protocol error.  Session setup failed.

Evidence that this is a jar conflict, not a network/credentials issue

All executed inside the same apache/seatunnel:latest container against the same PG 14 server (postgres:14-alpine, scram-sha-256):

  1. TCP reachable: bash -c "echo > /dev/tcp/postgres/5432" — OK
  2. Plain JDBC with only the bundled pgJDBC on the classpath — OK:
    java -cp /tmp:/opt/seatunnel/lib/postgresql-42.4.3.jar Trows=3
  3. Same connection through seatunnel.sh -m local (full lib/ classpath) — fails with "Protocol error. Session setup failed."
  4. Shadowing the openGauss jar with an empty file fixes it:
    docker run -v /tmp/empty.jar:/opt/seatunnel/lib/opengauss-jdbc-5.1.0.jar:ro ... → job FINISHED

Jar scan confirms three jars on the image contain org/postgresql/core/v3/ConnectionFactoryImpl:

  • /opt/seatunnel/lib/postgresql-42.4.3.jar (real driver)
  • /opt/seatunnel/lib/opengauss-jdbc-5.1.0.jar (conflicting fork)
  • /opt/seatunnel/connectors/connector-cdc-opengauss-2.3.13.jar

What you expected to happen

PostgreSQL connections work out of the box with the official image.

Suggested fixes (either):

  • move opengauss-jdbc out of the global lib/ and load it only with the openGauss connector's classloader, or
  • shade/relocate the org.postgresql packages inside the openGauss jar.

How to reproduce

docker network create t
docker run -d --name pg --network t -e POSTGRES_USER=u -e POSTGRES_PASSWORD=p -e POSTGRES_DB=d postgres:14-alpine
# minimal config: Jdbc source url jdbc:postgresql://pg:5432/d, user u, password p, query "SELECT 1", Console sink
docker run --rm --network t -v /path/to/job.conf:/j.conf apache/seatunnel:latest \
  /opt/seatunnel/bin/seatunnel.sh --config /j.conf -m local
# -> Protocol error. Session setup failed.

SeaTunnel Version

2.3.13 (apache/seatunnel:latest, digest sha256:2b1d327df210...)

SeaTunnel Config

env { parallelism = 1
  job.mode = "BATCH" }
source { Jdbc {
  url = "jdbc:postgresql://postgres:5432/analytics"
  driver = "org.postgresql.Driver"
  user = "bench"
  password = "..."
  query = "SELECT * FROM customers"
  plugin_output = "j" } }
sink { Console { plugin_input = "j" } }

Running Command

/opt/seatunnel/bin/seatunnel.sh --config /j.conf -m local

Error Exception

Caused by: org.apache.seatunnel.api.table.factory.FactoryException: ErrorCode:[API-06], ErrorDescription:[Factory initialize failed]
Caused by: org.apache.seatunnel.api.table.catalog.exception.CatalogException: ErrorCode:[API-03], ErrorDescription:[Catalog initialize failed]
Caused by: org.postgresql.util.PSQLException: Protocol error.  Session setup failed.

Zeta or Flink or Spark Version

Zeta (local mode)

Java or Scala Version

openjdk 1.8.0_342 (bundled in image)

Screenshots

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions