Skip to content

[ISSUE #7520] Reuse PostgreSQL initialization for openGauss. - #7530

Merged
Aias00 merged 6 commits into
apache:masterfrom
yangjj-iso:fix/7520-opengauss-shared-init
Oct 13, 2026
Merged

Aias00 merged 6 commits into
apache:masterfrom
yangjj-iso:fix/7520-opengauss-shared-init

Conversation

@yangjj-iso

@yangjj-iso yangjj-iso commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #7520.

Fresh PostgreSQL and openGauss installations now use db/init/pg/create-table.sql. The native SQL matrix, Agent Gateway seed checker and storage E2E setup use this shared source, and the separate current openGauss initialization copy is removed. OpenGauss profiles, JDBC/MyBatis integration and dialect-specific upgrade scripts remain in place. Upgrade validation continues to load the released openGauss schema from the immutable 2.7.1 baseline.

This changes fresh PostgreSQL installations as well as openGauss. The shared script removes orphan permissions, retains PostgreSQL's table definitions and effective resource grants, restores the intended custom rule-page defaults and Kafka selector handles, consolidates the Dubbo load-balance handle, and aligns loggingKafka/aiProxy plugin and default-namespace configurations. Existing installations continue using their version-specific upgrade scripts. The initialization guide documents the schema and seed decisions and installation commands.

The branch includes apache/shenyu:master at a89459bf2. The conflict resolution preserves the merged MySQL/OceanBase consolidation from #7529 alongside the PostgreSQL/openGauss checks: each pair retains its own fresh-schema validator, while OceanBase and openGauss upgrade flows keep their separate released baseline paths. The documentation describes both shared initialization sources. Historical SQL upgrade scripts are unchanged.

Validation:

  • Follow-up at 3d8693cc1: synchronized master at a89459bf2, with no shared PG/openGauss SQL change or merge conflicts. Re-ran 29 native-matrix runner tests, 11 migration tests and five dialect seed checks locally; all pass. On the preceding 4254922e9 head, GitHub native PostgreSQL/openGauss jobs, runner tests and migration checks also passed. The remaining HTTP E2E failures show external httpbin.org HTTP 503/timeouts; new CI was triggered by this push.

  • Latest update at 4254922e9: 115 WebSocket/dependency tests and 96 Admin mapper/service/import tests passed with zero failures/errors/skips. The upstream snapshot assertion now verifies applyPluginDataSnapshot(namespace, []), fixing the stale assertion that failed CI. The 29 native-matrix runner tests, 11 Agent Gateway migration tests and all five dialect seed checks passed; the affected 34-module dependency reactor passed Checkstyle and Apache RAT. Native database-engine checks below were previously run at b010fa094; this update does not alter the shared PostgreSQL/openGauss SQL. GitHub CI is rerunning on the updated head.

  • PostgreSQL 15 and openGauss lite 5.0.1: all four fresh-install and 2.7.1 upgrade flows passed using the digest-pinned Linux amd64 images. Fresh checks cover columns/nullability, primary keys, indexes, duplicate natural keys, JSON, resource grants and namespace defaults. The duplicate discovery-upstream insert is rejected by the intended unique index.

  • Native SQL runner regressions: 29 tests passed, including both OceanBase and openGauss historical-baseline selection and the actual storage schema-copy path.

  • Agent Gateway migration regressions: 11 tests passed. The seed checker passes for all five dialects, with 24 matching rows per dialect.

  • Admin plugin mapper/service/controller and query-index contracts: 72 tests passed, no failures/errors/skips; Checkstyle and Apache RAT passed for the 34-module dependency reactor.

  • git diff --check passed; no unresolved merge entries remain. The updated branch contains current master, so it can merge without conflicts.

python3 -B .github/scripts/test-native-sql-matrix.py
python3 -B .github/scripts/test-agent-gateway-migrations.py
python3 -B .github/scripts/check-agent-gateway-migrations.py
python3 -B .github/scripts/native-sql-matrix.py --dialect pg --output /tmp/shenyu-7530-audit-pg
python3 -B .github/scripts/native-sql-matrix.py --dialect og --output /tmp/shenyu-7530-audit-og
./mvnw -B -ntp -pl shenyu-admin -am \
  -Dtest=PluginMapperTest,PluginServiceTest,PluginControllerTest,AdminQueryIndexTest,PluginIndexUpgradeContractTest \
  -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false \
  -Djacoco.skip=true -Dmaven.javadoc.skip=true test apache-rat:check

The complete gateway/storage E2E suite and full repository install were not run locally. GitHub CI must validate the updated merge head.

@wy471x wy471x left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed locally at fcb6092, checked against the merge base with master (380afb5):

  • CI scripts pass on this head: test-native-sql-matrix.py (26 tests OK) and test-agent-gateway-migrations.py (10 tests OK — all five seeds report 24 matching Agent Gateway rows).
  • Comparing the deleted db/init/og/create-table.sql with the reconciled db/init/pg/create-table.sql: the 40 openGauss-only grant pairs all reference resources that do not exist in the PostgreSQL resource table, and 15 further rows duplicate a (role, resource) grant that already exists under a different id — no effective grant is lost.
  • The openGauss-only plugin_handle rows are exactly the intended cleanups: the stale Dubbo loadBalance/loadStrategy duplicate (the proper loadBalance handle remains), and two rows where PostgreSQL's copy is the correct one — basicAuth's defaultHandleJson ext_obj is unescaped/invalid JSON in the openGauss seed and properly escaped in PostgreSQL, and indexName for loggingElasticSearch carries required:1. The cache plugin's cacheType/timeoutSeconds rows exist in both files (only the id prefixes differ), so nothing is dropped there.

Same two structural requests as the OceanBase sibling (#7529):

  1. Rebase needed. git merge-tree --write-tree gh/master <head> reports a modify/delete conflict on db/init/og/create-table.sql — master removed 68 orphan permission rows from that file after your base (same cleanup class, so this should resolve cleanly once you re-run the seed reconciliation on top of current master).
  2. State the scope. The PR also edits db/init/pg/create-table.sql, so it changes what a fresh PostgreSQL install gets, not only openGauss. Please say so in the description (or split it); that is the part of the diff a PostgreSQL user actually experiences.

Documenting each schema/seed decision in the initialization guide, and adding the duplicate-natural-key / invalid-JSON / grant checks to the native matrix, is the right call for this kind of consolidation — much easier to review than the deleted duplicate scripts were.

@github-actions
github-actions Bot force-pushed the fix/7520-opengauss-shared-init branch from fcb6092 to b491697 Compare October 11, 2026 02:13
Aias00
Aias00 previously approved these changes Oct 11, 2026

@Aias00 Aias00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review: [ISSUE #7520] Reuse PostgreSQL initialization for openGauss

Approved. A clean and well-reasoned consolidation of the openGauss initialization onto the PostgreSQL schema.

What's good

  • Fresh-install openGauss now reuses db/init/pg/create-table.sql: native-sql-matrix.py now maps og to "db/init/pg/create-table.sql" (was db/init/og/create-table.sql), and the entire 2418-line db/init/og/create-table.sql is deleted. The e2e script storage_init_opengauss.sh is updated accordingly (cp db/init/pg/create-table.sql ...).
  • Upgrade compatibility is preserved correctly: the matrix's og + upgrade flow still validates against the historical git show {BASELINE}:db/init/og/create-table.sql (the released openGauss schema), and test-native-sql-matrix.py explicitly asserts the working-tree db/init/og/create-table.sql no longer exists (assertFalse). This is the right design — fresh installs converge, but upgrade drift is still caught against the prior release.
  • The PostgreSQL file is brought to a superset of the two dialects: the additions add the plugin/plugin_handle/namespace_plugin_rel seeds (aiProxy, paramMapping, modifyResponse, loggingKafka, default-namespace bindings) that openGauss previously carried, and the deletions remove duplicate permission seed rows to reconcile the two schemas. The schema now carries a "Shared fresh-install schema for PostgreSQL and openGauss" header.
  • native-sql-matrix.md and the new test-native-sql-matrix.py document and validate the shared matrix; check-agent-gateway-migrations.py and test-agent-gateway-migrations.py are adjusted in tandem.

Verification / CI

  • build, the full shenyu-integrated-test-* matrix, agent_gateway_migrations, and CodeQL all pass. The native-sql-matrix is the gate for the pg/og seed reconciliation.
  • The e2e failure shown (e2e-logging-rocketmq-compose) is the fleet-wide rocketmq-logging e2e job and is unrelated to this DB-init PR (no logging/rocketmq code is touched here). Not blocking.

Non-blocking follow-ups

  • Please confirm the removed permission seed rows (consecutive-ID chunks, e.g. 1529403932881850584..592, 1572525965658820609..617) are genuine duplicates rather than intended distinct entries — they look like dedup, and the matrix validates seeds, but a second set of eyes on the content is worth it.
  • Same for the added plugin seeds (aiProxy/paramMapping/modifyResponse/loggingKafka): ensure they are intended for both pg and og fresh installs (they now are, by construction).

ci: build + integrated-tests + migrations green; e2e infra failure unrelated. Merging.

@Aias00

Aias00 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Hi @yangjj-iso, this PR currently has merge conflicts with the master base branch, so CI cannot validate it against the latest code. Please rebase/merge the latest master and resolve the conflicts, then push the updated branch. Once the conflicts are cleared, CI will re-run automatically and we can continue the review. Thanks!

@Aias00 Aias00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reuses the PostgreSQL fresh-install schema for openGauss (deletes the duplicate db/init/og/create-table.sql and routes og fresh/upgrade validation to the shared PG source). The change genuinely removes duplication, leaves every other dialect untouched, preserves the og upgrade path via the git baseline, and ships meaningful CI checks — APPROVE with one pre-merge verification.

No blocking defects found

The PR does what it claims. Below are the non-blocking observations and the single item that must be green in CI before merge.

Notes

  • Pre-merge verification (critical, not a defect): db/upgrade/2.7.1-upgrade-2.7.2-og.sql is not part of this diff, yet check-agent-gateway-migrations.py now validates the og dialect against db/init/pg/create-table.sql (schema) vs db/upgrade/2.7.1-upgrade-2.7.2-og.sql (migration). The new test test_opengauss_uses_shared_schema_and_its_own_upgrade writes the real pg/create-table.sql and the real og upgrade into a temp tree and asserts CHECK.check(root) passes (only a deliberately corrupted upgrade raises og: fresh-install/upgrade mismatch). That test, together with the existing test_all_dialects_match, is exactly the guard that would catch a reconciliation mismatch — so the design intent (pg fresh == og upgrade target) is verified by CI, not by inspection. Confirm the CI run for this PR passes test-agent-gateway-migrations and test-native-sql-matrix. I could not execute these locally (the provided repo snapshot contains no working tree and gh is disallowed), so this is the one fact I could not personally confirm.

  • SENTINEL reference in the new check_fresh_postgres_seeds: check_fresh_postgres_seeds (native-sql-matrix.py) uses SENTINEL (e.g. p.id<>'{SENTINEL}'). Confirm SENTINEL is defined at module scope. An undefined name would break module import and fail all matrix tests. Low risk — the existing check_fresh_mysql_schema already relies on the same constant (verify by grepping the module).

  • Residual on-disk references to db/init/og/create-table.sql: The file is deleted from the working tree and now exists only at the immutable git baseline (mirroring the already-deleted db/init/ob/schema.sql pattern, which is read via git show {BASELINE}:db/init/ob/schema.sql). Grep the repo (e2e scripts, docker/compose, docs, and any Java DB-init code that may resolve og/create-table.sql from the classpath) to ensure nothing still expects it on disk. The two known references (storage_init_opengauss.sh and both CI scripts) are already updated in this PR.

  • nit: The verify_index_rows change from column.strip().strip('"') to column.strip().split()[0].strip('"') correctly handles pg_catalog-decorated index columns (e.g. (plugin_id COLLATE pg_catalog."default" …)) and is exercised by the new test_pg_and_og_catalogs sub-case. No action needed.

What the review confirmed

  1. Genuine de-duplication, not relocation: db/init/og/create-table.sql (2,891 lines) is fully deleted; both check-agent-gateway-migrations.py (schema_dialect = {"ob": "mysql", "og": "pg"}) and native-sql-matrix.py (DIALECTS["og"][1] == DIALECTS["pg"][1], asserted by test_opengauss_shares_current_postgres_schema_but_keeps_released_baseline) now resolve the og fresh-install schema to db/init/pg/create-table.sql. The shared pg/create-table.sql is then enriched to become the canonical PG+openGauss 2.7.2 fresh state (removed orphan permission seeds, ruleHandlePageType for paramMapping/modifyResponse, bootstrapServer for loggingKafka, loadBalance spelling/default for Dubbo, unique discovery_upstream_discovery_handler_id_idx — fixing a previously non-unique-but-renamed index — and aiProxy fallback without the obsolete prompt field).

  2. Other dialects untouched: Only pg/og paths in the scripts and the two pg/og SQL files changed. mysql, ob, oracle, h2 init/upgrade paths and their CI wiring are unchanged. The og upgrade flow still reads its historical db/init/og/create-table.sql via git show {BASELINE}:… (same mechanism as ob), so existing openGauss installations upgrading from 2.7.1 are unaffected.

  3. Tests are meaningful, not empty shells: test_opengauss_uses_shared_schema_and_its_own_upgrade runs the real CHECK.check and proves a one-character upgrade mutation is detected; test_opengauss_storage_initialization_copies_the_shared_schema actually executes the k8s storage script (with mkdir/wget/cp mocked) and asserts the copied bytes equal pg/create-table.sql; the new check_fresh_postgres_schema/check_fresh_postgres_seeds/check_discovery_upstream_uniqueness perform real column/nullability/primary-key/index/JSON/orphan checks and a live duplicate-insert rejection against the engine. These exercise the exact behavior the PR changes.

Conclusion

APPROVE.

Key verified facts:

  • The duplicate openGauss init script is genuinely removed and openGauss now shares PostgreSQL's pg/create-table.sql across the CI matrix, the migration checker, the storage script, and the init guide.
  • MySQL/Oracle/OpenGauss-upgrade/H2 paths are not regressed; the og upgrade continues via the git baseline, identical to the existing ob convention.
  • The added tests are substantive and directly exercise the new shared-schema contract (including a deliberate mismatch that must be caught).

One action before merge: ensure CI is green for test-agent-gateway-migrations / test-native-sql-matrix (the og-against-pg-fresh consistency is validated only by those tests, which I could not run locally).

@yangjj-iso

Copy link
Copy Markdown
Contributor Author

Thanks. The requested checks passed on 4254922: Agent Gateway migrations, native-matrix runner tests, PostgreSQL native checks, and openGauss native checks. I also reran the 29 matrix tests, 11 migration tests and all five dialect seed checks locally today; they all pass. SENTINEL is defined at module scope. A repository-wide search found the deleted og path only in the historical baseline lookup, its regression assertions and upgrade documentation; no current initialization consumer expects the deleted file on disk.

The remaining failures in that run were the PostgreSQL storage and ZooKeeper cluster HTTP E2E cases: the logs show public httpbin.org returning HTTP 503 or timing out, rather than SQL initialization failures (storage log, cluster log). I cannot rerun upstream Actions jobs with this account's permissions. I have pushed 3d8693c, syncing master at a89459b and triggering a fresh CI run. The shared PG/openGauss SQL is unchanged by this follow-up, and there are no merge conflicts.

@Aias00
Aias00 merged commit fb19778 into apache:master Oct 13, 2026
39 checks passed
@Aias00 Aias00 added this to the 2.7.2 milestone Nov 13, 2026
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.

[Task] Reuse PostgreSQL initialization SQL for openGauss and remove the duplicate script

3 participants