Skip to content

refactor(cloudsql): run data-plane SQL via in-container psql, drop JDBC driver#68

Merged
hectorvent merged 1 commit into
mainfrom
refactor/cloudsql-psql-exec
Jun 19, 2026
Merged

refactor(cloudsql): run data-plane SQL via in-container psql, drop JDBC driver#68
hectorvent merged 1 commit into
mainfrom
refactor/cloudsql-psql-exec

Conversation

@hectorvent

@hectorvent hectorvent commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

The Cloud SQL data plane opened JDBC connections from the emulator to the spawned Postgres sidecar to run admin SQL (CREATE DATABASE/ROLE, grants, readiness). That required the org.postgresql JDBC driver, which does not work in the native image (DriverManager: No suitable driver found) and depended on the emulator reaching the sidecar over the network.

Run the admin SQL with psql via docker exec inside the instance container instead (readiness via pg_isready; both over TCP so they wait past the image's socket-only init server). The emulator no longer needs a JDBC driver at all — org.postgresql is removed from the project entirely. Adds ContainerLifecycleManager.exec(...) (the docker-java exec classes are already registered for native reflection).

The in-module CloudSqlDataPlaneIntegrationTest (which connected to the real Postgres endpoint as a JDBC client) is removed: it duplicated the compat suite's CloudSqlAdminTest, which already provisions instances for the latest Postgres versions and verifies the endpoint over JDBC — the right home for a real, network-level client test (and it keeps its own driver dependency).

Type of change

  • Bug fix (fix:)
  • New feature (feat:)
  • Breaking change (feat!: or fix!:)
  • Docs / chore

GCP Compatibility

No wire-protocol change. Resolves the native-image Cloud SQL provisioning hang (an infinite Postgres-container retry loop, because each ensureInstance re-ran startInstance and every JDBC connect failed). Verified natively: instances reach RUNNABLE in ~4s and CREATE DATABASE/CREATE ROLE actually create the objects in Postgres; compat-terraform/compat-opentofu (which provision a real google_sql_database_instance) now pass, and the compat CloudSqlAdminTest continues to verify endpoint usability over JDBC.

Checklist

  • ./mvnw test passes locally (15 Cloud SQL unit tests)
  • New or updated integration test added — real data-plane verification lives in compatibility-tests/sdk-test-java (CloudSqlAdminTest)
  • Commit messages follow Conventional Commits

@hectorvent hectorvent force-pushed the refactor/cloudsql-psql-exec branch from d87ed4f to 87953a2 Compare June 18, 2026 23:45
…BC driver

The Cloud SQL data plane opened JDBC connections from the emulator to the spawned
Postgres sidecar to run admin SQL (CREATE DATABASE/ROLE, grants, readiness). That
required the org.postgresql JDBC driver, which does not work in the native image
(DriverManager: "No suitable driver found", since the java.sql.Driver ServiceLoader
isn't registered) and depended on the emulator reaching the sidecar over the network.

Run the admin SQL with `psql` via `docker exec` inside the instance container
instead (readiness via `pg_isready`; both over TCP to the real server so they wait
past the image's socket-only init server). The emulator no longer needs a JDBC
driver at all — `org.postgresql` is removed from the project entirely. Adds
ContainerLifecycleManager.exec(...).

The in-module CloudSqlDataPlaneIntegrationTest (which connected to the real Postgres
endpoint as a JDBC client) is removed: it duplicated the compat suite's
CloudSqlAdminTest, which already provisions instances for the latest Postgres
versions and verifies the endpoint over JDBC — the right home for a real,
network-level client test.

Verified natively: instances reach RUNNABLE in ~4s and CREATE DATABASE/CREATE ROLE
actually create the objects.
@hectorvent hectorvent force-pushed the refactor/cloudsql-psql-exec branch from 87953a2 to 80f8e01 Compare June 18, 2026 23:52
@hectorvent hectorvent merged commit a100848 into main Jun 19, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant