-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[wip]feat(backend): postgres integration #12379
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
base: master
Are you sure you want to change the base?
Conversation
|
Hi @kaikaila. Thanks for your PR. I'm waiting for a kubeflow member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
🚫 This command cannot be processed. Only organization members or owners can use the commands. |
cd1d08b to
85498ed
Compare
|
Currently, both MySQL and PGX setups use the DB superuser for all KFP operations, which is why client_manager.go contains a “create database if not exist” step here. From a security standpoint, would it be preferable to:
If the team agrees, I can propose a follow-up PR to refactor accordingly. |
|
I'm fine with this, I don't think it's great that KFP tries to create a database (or a bucket frankly) fyi @mprahl / @droctothorpe |
|
Thanks, @HumairAK — totally agree on the security point. |
09fd370 to
1e0caa8
Compare
|
yes that is fine |
4d33821 to
e6c943c
Compare
Question about the PostgreSQL test workflow organizationCurrent situationThe V2 integration tests for PostgreSQL logically belong in a "PostgreSQL counterpart" to legacy-v2-api-integration-tests.yml Question: What's the recommended workflow organization for PostgreSQL tests?Should I:
Would love guidance on the long-term vision for test workflow organization, especially from @nsingla |
e038969 to
c81e91a
Compare
I actually would like to get rid of these legacy tests asap, but there are still few tests that needs to be migrated first, so my suggestion is to not add more work to the legacy workflows |
nsingla
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 big difference between Mysql and Postgres is that Mysql is case insensitive whereas postgres is, so can we actually add test cases to verify searches with cases sensitivity and insensitivity? we can probably implement these test cases in https://github.com/kubeflow/pipelines/blob/master/backend/test/v2/api/pipeline_api_test.go#L125, to filter by name containing upper case letter
eb68f89 to
1ded0c7
Compare
6fe55fe to
a6cce78
Compare
e318f11 to
afe5e6a
Compare
Signed-off-by: kaikaila <[email protected]>
Signed-off-by: kaikaila <[email protected]>
…iveExperiment - Extract repeated subquery SQL into resourceReferenceSubquery variable - Unify code style: consistently use SetMap() throughout - Add detailed comments explaining PostgreSQL $N placeholder handling - Simplify error messages optimization according to sanchesoon's suggestion Signed-off-by: kaikaila <[email protected]>
1. dialect.go: fmt.Sprintf for sql string 2. merge review diff from Humair *_store.go: replace sql string concatenating with fmt.Sprintf reuse escapeSQLString from dialect.go replace == with erros.Is() replace t.Errorf with require or assert; replace t.Fatalf with require.FailNow in integration test hardcode expectations rename QuoteFunction QualifyIdentifier in storage package unit tests for qualifyIdentifier parametized timeout as a constant make target dev-kind-cluster with DB parameter revert dev-kind-cluster bridge to 172.17.0.1 for linux cleaning redundant postgres config in configmap add database parameter to api-server-test standalone only add CI job for postgres with argo 3.6.7 database ”" to “mysql” Signed-off-by: kaikaila <[email protected]>
Signed-off-by: kaikaila <[email protected]>
Signed-off-by: kaikaila <[email protected]>
Signed-off-by: kaikaila <[email protected]>
Signed-off-by: kaikaila <[email protected]>
…abase-agnostic sorting Signed-off-by: kaikaila <[email protected]>
…irst yaml file for smoke tests Signed-off-by: kaikaila <[email protected]>
Signed-off-by: kaikaila <[email protected]>
af3a6cd to
129ae6a
Compare
Signed-off-by: kaikaila <[email protected]>
Summary
This PR adds full PostgreSQL (pgx driver) support to Kubeflow Pipelines backend, enabling users to choose between MySQL and PostgreSQL as the metadata database. The implementation introduces a clean dialect abstraction layer and includes a major query optimization that benefits both database backends.
Key achievements
✅ Complete PostgreSQL integration for API Server and Cache Server, addressing #7512, #9813
✅ All CI tests passing (MySQL + PostgreSQL).
✅ Significant performance improvement for ListRuns queries. This PR is expected to address the root causes behind #10778, #10230, #9780, #9701
✅ Zero breaking changes - backward compatible with existing MySQL deployments
What Changed
Problem
SQL syntax was tightly coupled to MySQL.
Solution
Introduced a DBDialect interface that encapsulates database-specific behavior
Identifier quoting (MySQL backticks vs PostgreSQL double quotes)
Placeholder styles (? vs $1, $2, ...)
Aggregation functions (GROUP_CONCAT vs string_agg)
Concatenation syntax (CONCAT() vs ||)
Files
backend/src/apiserver/common/sql/dialect/dialect.gobackend/src/apiserver/storage/sql_dialect_util.gobackend/src/apiserver/storage/list_filters.goAll storage layer code now uses
This ensures queries work correctly across MySQL, PostgreSQL, and SQLite (for tests).
The original ListRuns query called
addMetricsResourceReferencesAndTaskswhich performed a 3-layer LEFT JOIN with GROUP BY on all columns, includingLONGTEXTfields likePipelineSpecManifestWorkflowSpecManifestetc. This caused slow response times for large datasets.Layers 1-3: LEFT JOIN only on PrimaryKey
UUID+ aggregated columns (refs, tasks, metrics)Final layer: INNER JOIN back to run_details to fetch
LONGTEXTcolumnsEliminates GROUP BY on LONGTEXT columns entirely. Expected substantial performance improvements for deployments with large pipeline specifications, though formal load testing has not yet been conducted.
manifests/kustomize/env/platform-agnostic-postgresql/manifests/kustomize/env/dev-kind-postgresql/manifests/kustomize/third-party/postgresql/Configuration is symmetric to existing MySQL manifests for consistency.
Created CI-specific Kustomize overlays to ensure tests use locally built images from the Kind registry instead of pulling official images from ghcr.io:
.github/resources/manifests/standalone/postgresql/kfp-cache-serverimage override to.github/resources/manifests/standalone/base/kustomization.yamlapi-server-test-Postgres.ymlintegration-tests-v1-postgres.ymlPostgreSQL tests cover the core cache enabled/disabled matrix.
Testing
Unit Tests
23 test files modified/added
New test coverage: dialect_test.go, list_filters_test.go, sql_dialect_util_test.go
All existing tests updated to use dialect abstraction
Integration Tests
✅ V1 API integration tests (PostgreSQL)
✅ V2 API integration tests (PostgreSQL, cache enabled/disabled)
✅ Existing MySQL tests remain green
Migration Guide
kubectl apply -k manifests/kustomize/env/platform-agnostic-postgresqlNo action required. This PR is fully backward compatible.
make -C backend dev-kind-cluster-pgThis PR continues from #12063.