Skip to content

Defer meta data refresh to transaction commit for DDL in PostgreSQL transaction - #39882

Open
rishi-rana wants to merge 20 commits into
apache:masterfrom
rishi-rana:defer-metadata-refresh-in-transaction
Open

rishi-rana wants to merge 20 commits into
apache:masterfrom
rishi-rana:defer-metadata-refresh-in-transaction

Conversation

@rishi-rana

@rishi-rana rishi-rana commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #35166.

Changes proposed in this pull request:

Meta data refresh runs immediately after execute, over a new physical connection, so it cannot see DDL that the current transaction has not committed yet. This PR defers the refresh to commit.

  • Add DeferredMetaDataRefreshContext, a transaction-scoped queue of pending push down refreshes held by ProxyDatabaseConnectionManager. It stores the database name rather than a ShardingSphereDatabase reference, so the database is re-resolved when the refresh actually runs.
  • StandardDatabaseProxyConnector#doExecute now enqueues the refresh when the session is in a transaction, and refreshes immediately otherwise. The existing DDLCommitPolicy.COMMIT_CURRENT_TRANSACTION path is unchanged: it commits first, so the refresh still runs immediately.
  • ProxyBackendTransactionManager drains the queue after the underlying commit succeeds and before the connection context is cleared, discards it on rollback, records the queue position on SAVEPOINT, and rolls back to that position on ROLLBACK TO SAVEPOINT.
  • Set isSupportMetaDataRefreshInTransaction to true for PostgreSQL. ProxySQLExecutor#checkExecutePrerequisites rejects metadata-changing DDL in a transaction while that flag is false, so the deferral mechanism and the flag have to change together.

Notes on scope:

  • This covers XA and BASE as well. ProxyBackendTransactionManager#commit is the single commit entry point for all three transaction types, with the local/distributed split inside it, so the deferral is transaction-type agnostic. PostgreSQL already declared isSupportDDLInXATransaction = true, so this adds no new claim about XA beyond making the refresh correct.
  • Rolling back to a savepoint must drop the refreshes recorded after it. DropTablePushDownMetaDataRefresher removes the table from meta data purely from the statement rather than reloading it, so keeping a rolled-back DROP TABLE in the queue would delete a still-existing table from meta data.
  • The deferred refreshes are only rolled back when the savepoint rollback succeeded on every connection. If it failed, the DDL is still applied and its refresh must be kept.
  • DriverJDBCPushDownExecuteExecutor and DriverJDBCPushDownExecuteUpdateExecutor have the same immediate-refresh shape, so ShardingSphere-JDBC appears to have the analogous behaviour. They never read isSupportMetaDataRefreshInTransaction, so this PR does not change them. Happy to open a separate issue if you would like that covered.

Tests:

  • DeferredMetaDataRefreshContextTest covers the queue and savepoint semantics.
  • ProxyBackendTransactionManagerTest covers the drain ordering relative to commit, the discard on rollback, and the savepoint mark and rollback wiring.
  • StandardDatabaseProxyConnectorTest covers deferring instead of refreshing while in a transaction.
  • PostgreSQLDDLMetaDataRefreshTestCase is a transaction E2E case running the BEGIN / ALTER TABLE ADD COLUMN / COMMIT sequence from the issue against Proxy, asserting the new column becomes visible without a manual REFRESH TABLE METADATA, and that a rolled back column does not. It compiles locally but I have not run the Docker-backed E2E suite on my machine, so please treat CI as the authority for it.

Local verification:

  • ./mvnw -pl proxy/backend/core,database/connector/dialect/postgresql test — 597 tests, 0 failures.
  • ./mvnw -pl proxy/backend/core,database/connector/dialect/postgresql spotless:check checkstyle:check -Pcheck — 0 violations.
  • ./mvnw apache-rat:check -Pcheck — passed.
  • Each new test was confirmed to fail against the unfixed implementation before being accepted.

Before committing this PR, I'm sure that I have checked the following options:

  • My code follows the code of conduct of this project.
  • I have self-reviewed the commit code.
  • I have (or in comment I request) added corresponding labels for the pull request.
  • I have passed maven check locally : ./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e. I ran the targeted module builds, style checks and RAT listed above rather than the full reactor build; please let me know if you would like the full build result before review.
  • I have made corresponding changes to the documentation.
  • I have added corresponding unit tests for my changes.
  • I have updated the Release Notes of the current development version.
  • I have disclosed the tool and affected files or scope for any material AI assistance, as required by the AI-assisted contribution policy.

AI assistance disclosure, per AI_POLICY.md: this change was assisted by AI (Claude Code), covering the investigation, implementation and tests across all files in this PR, under my review and with the verification listed above.

@rishi-rana
rishi-rana force-pushed the defer-metadata-refresh-in-transaction branch from 3da5f5b to 1cf2aad Compare September 17, 2026 16:30

@terrymanu terrymanu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Result

Review Result: Not Mergeable

Feedback Mode: Change Request

Blocking Issues: 2

The deferred-refresh design causes a cross-dialect regression and cannot safely replay multiple transactional DDL statements.

Blocking Issues

  1. [P1] Preserve immediate refresh for implicit-commit dialects

    Evidence: StandardDatabaseProxyConnector.java:252 now defers every metadata refresh whenever the logical session is in a transaction, without considering the backend dialect. MySQLDatabaseMetaData.java:85 retains NO_ADDITIONAL_COMMIT, so ShardingSphere does not clear the transaction before entering this branch. On rollback, ProxyBackendTransactionManager.java:171 discards the queued refresh. MySQL documents that ordinary CREATE TABLE and other listed DDL statements implicitly commit the active transaction. MySQL 8.4 Reference Manual

    Impact: With BEGIN; CREATE TABLE t (...); ROLLBACK;, MySQL commits the table creation, but this PR discards its metadata refresh. The table remains physically present while ShardingSphere metadata remains stale.

    Required Change: Defer only when the backend keeps DDL uncommitted and invisible to the refresh connection. Preserve immediate refresh for implicit-commit dialects and add a regression test covering MySQL DDL followed by rollback.

  2. [P1] Do not replay statement-local refreshers against the transaction’s final state

    Evidence: DeferredMetaDataRefreshContext.java:50 stores each original statement and DeferredMetaDataRefreshContext.java:87 replays them after every DDL has committed. The existing create-table refresher reloads the statement’s original table name (CreateTablePushDownMetaDataRefresher.java:51); when that name no longer exists, the loader returns null (TableMetaDataRefresherLoader.java:89), which the standalone service dereferences (StandaloneMetaDataManagerPersistService.java:113). The one-storage-unit routing path allows both statements to reach the database without requiring refreshed metadata (SingleSQLRouter.java:52).

    Impact: For PostgreSQL, BEGIN; CREATE TABLE t (...); ALTER TABLE t RENAME TO u; COMMIT; commits successfully at the database, then replay attempts to load the now-absent t, fails before processing the rename, reports a commit error after the physical commit, and leaves u absent from ShardingSphere metadata.

    Required Change: Represent the final committed metadata effects rather than replaying unchanged statement-local refreshers. Coalesce operations or perform a transaction-level reload that handles renamed and removed objects, with regression coverage for sequences such as create-plus-rename and create-plus-drop.

Coverage

  • Candidate: public PR #39882, Code Correctness Review.
  • Effective head: 62a116f429ba317bbadb26bc3b74425f9dff8bee.
  • Base: master at 86c1519e4d6deaf68e18ee47196e81da2e114f62; merge base 101c3d56ccd7ee3c4a390a8f37550bed58a4751c.
  • GitHub’s 13-file list matched the independently reconstructed triple-dot scope.
  • All behavior clusters were reviewed:
    • PostgreSQL capability activation and prerequisite tests.
    • Deferred enqueue, transaction lifecycle, savepoints, commit, and rollback.
    • Unit/E2E coverage and E2E registration.
    • Release-note and AI-assistance disclosure requirements.
  • Root-cause, blast-radius/contracts, tests/runtime/operations, and final convergence passes completed. No unresolved evidence gaps remain.
  • Mandatory style verification:
    • ./mvnw -pl database/connector/dialect/postgresql,proxy/backend/core,test/e2e/operation/transaction spotless:check checkstyle:check -Pcheck -T1C
    • Exit code: 0; Spotless covered 26, 243, and 60 Java files in the three modules, and Checkstyle reported zero violations in each.
    • Both checks covered all 11 changed Java files.
    • RELEASE-NOTES.md and test/e2e/operation/transaction/src/test/resources/env/e2e-env.properties are not governed by the configured Java/POM/workflow Spotless formats or Java Checkstyle scope.
  • Focused verification passed:
    • PostgreSQL metadata and four proxy test classes: 116 tests, zero failures/errors.
    • Transaction E2E module test compilation: 60 sources compiled successfully.
    • Docker-backed E2E execution was not run; it is not outcome-sensitive to the two code-proven blockers.
  • CI/Actions were not reviewed. This is a code-scope result only; local style verification is complete.

@rishi-rana

Copy link
Copy Markdown
Contributor Author

Thanks for both findings. Addressed in 5c5ea8b.

DeferredMetaDataRefreshContext collects the tables touched by DDL as (database, schema, table) and calls ContextManager#reloadTable for each once the transaction ends. That reads the committed state of every affected table, and persistTable reconciles both directions: present in the database means the table is persisted, absent means it is dropped from meta data.

1. Implicit-commit dialects

Reloading committed state makes the outcome independent of how the backend treats DDL, so the implementation does not branch on dialect and no dialect capability is introduced. A rollback reloads the affected tables:

  • MySQL BEGIN; CREATE TABLE t; ROLLBACK; reloads t, finds it present because the server committed it implicitly, and persists it.
  • PostgreSQL BEGIN; CREATE TABLE t; ROLLBACK; reloads t, finds it absent, and leaves meta data unchanged.

Regression coverage is MySQLDDLMetaDataRefreshTestCase, an E2E case asserting that a column added inside a transaction and then rolled back is present in meta data on MySQL. It is an E2E rather than a unit test because the behaviour under test is the MySQL server's implicit commit, which needs a real MySQL backend to demonstrate. ProxyBackendTransactionManagerTest covers the mechanism, asserting that a rollback reloads and does so after the underlying rollback.

2. Replaying statement-local refreshers

Statements are not replayed, so a refresher cannot run against a table name that a later statement in the same transaction removed. ALTER TABLE t RENAME TO u contributes both names, because AlterTableStatement#getTables includes the rename target, so the reload drops t and persists u. CREATE TABLE t; DROP TABLE t; reloads t, finds it absent, and drops it. ContextManager#reloadTable logs rather than propagates SQLException, so a reload problem does not surface as a commit error after the physical commit has succeeded.

Savepoint tracking is not required, because reloading final state is already correct after a partial rollback.

Verification

  • ./mvnw -pl proxy/backend/core,database/connector/dialect/postgresql test - 592 tests, 0 failures.
  • Transaction E2E on mysql:5.7 - passed, including the new MySQL case.
  • Transaction E2E on postgres:12-alpine - passed.
  • spotless:check and checkstyle:check -Pcheck across the three changed modules - 0 violations; apache-rat:check -Pcheck - passed.

@terrymanu terrymanu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Result

Review Result: Not Mergeable

Feedback Mode: Change Request

Blocking Issues: 3

The deferred-refresh representation loses required metadata semantics, refreshes implicit-commit dialects too late, and is protected by tests that do not exercise a reachable production DDL path.

Blocking Issues

  1. [P1] Preserve object type and identifier semantics in deferred refreshes

    Evidence: refreshMetaData converts every supported metadata-changing DDL into (database, schema, Collection<String> tableNames). The refresh engine also supports schema and view statements (PushDownMetaDataRefreshEngine.java:58), but schema statements have no table attribute, while view refreshers must update both table and view metadata (CreateViewPushDownMetaDataRefresher.java:43). The deferred context only invokes reloadTable (DeferredMetaDataRefreshContext.java:46).

    The conversion also discards identifier quoting: TablesContext stores only IdentifierValue#getValue() (TablesContext.java:69), and reloadTable(String) recreates an unquoted identifier (ContextManager.java:220). PostgreSQL’s identifier policy distinguishes quoted mixed-case identifiers from unquoted lower-case identifiers.

    Impact: BEGIN; CREATE SCHEMA s; COMMIT queues nothing, transactional view DDL never updates the view registry, and DDL against a quoted table such as "MixedCase" can take the “table missing” drop path instead of persisting the reloaded table.

    Required Change: Represent every supported deferred metadata effect with its object type and complete identifier semantics. Add transactional regression coverage for schema DDL, view DDL, and quoted PostgreSQL table names.

  2. [P1] Preserve immediate refresh for implicit-commit dialects

    Evidence: MySQL retains DDLCommitPolicy.NO_ADDITIONAL_COMMIT while permitting metadata refresh in transactions (MySQLDatabaseMetaData.java:83). The shared connector nevertheless defers whenever the logical transaction flag remains set. Reloading occurs only during a later Proxy commit or rollback. The new E2E test itself documents that MySQL commits the DDL implicitly, but checks metadata only after calling rollback (MySQLDDLMetaDataRefreshTestCase.java:33).

    Impact: After MySQL physically commits ALTER TABLE, shared ShardingSphere metadata remains stale until the originating client eventually sends a logical commit or rollback. Other sessions can observe the committed database change while Proxy still holds the old metadata. Reloading after rollback fixes the previous stale endpoint but not this interval.

    Required Change: Refresh immediately when backend DDL has already committed, or restrict deferral to dialects whose DDL remains transactional. The MySQL E2E case should assert metadata correctness before the later rollback.

  3. [P2] Exercise a reachable DDL path and follow the test standards

    Evidence: assertExecuteDefersMetaDataRefreshInTransaction constructs an InsertStatement and forces PushDownMetaDataRefreshEngine#isNeedRefresh() to return true. Production returns true only for the listed DDL statement classes, so this combination is unreachable and cannot detect the failures above. The test also adds direct construction/static mocking without the required recorded reason, and DeferredMetaDataRefreshContextTest.java:59 uses redundant times(1), contrary to CODE_OF_CONDUCT.md:104.

    Impact: The focused suite passes while the actual DDL extraction and deferred representation are broken.

    Required Change: Exercise the connector with real supported DDL contexts, cover the affected object and identifier cases, use the repository mock extension where applicable or record why it cannot apply, and replace times(1) with plain verify.

Coverage

  • Candidate: public PR #39882, Code Correctness Review.
  • Effective head: 5c5ea8bc04097599338aff374bb0b26ad0ce76bc.
  • Base: master at 86c1519e4d6deaf68e18ee47196e81da2e114f62; merge base 101c3d56ccd7ee3c4a390a8f37550bed58a4751c.
  • GitHub’s authoritative 14-file list matched the merge-base comparison and remained unchanged after verification.
  • All behavior clusters were reviewed: PostgreSQL capability activation; deferred enqueue and transaction lifecycle; table/schema/view/index refresh contracts; identifier handling; MySQL implicit-commit compatibility; unit/E2E coverage and registration; release notes.
  • Previous feedback was re-evaluated: statement replay is removed; the implicit-commit rollback endpoint is fixed, but the refresh-timing regression remains.
  • Root-cause, blast-radius/contracts, tests/runtime/operations, and final convergence passes completed. No unresolved evidence gaps remain.
  • Mandatory style verification:
    • Command: ./mvnw -pl database/connector/dialect/postgresql,proxy/backend/core,test/e2e/operation/transaction spotless:check checkstyle:check -Pcheck -T1C
    • Exit code: 0; Spotless checked 26, 243, and 61 Java files respectively, and Checkstyle reported zero violations.
    • Covered all 12 changed Java files:
      • database/connector/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/connector/postgresql/metadata/database/PostgreSQLDatabaseMetaData.java
      • database/connector/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/connector/postgresql/metadata/database/PostgreSQLDatabaseMetaDataTest.java
      • proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/ProxyDatabaseConnectionManager.java
      • proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/StandardDatabaseProxyConnector.java
      • proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/transaction/DeferredMetaDataRefreshContext.java
      • proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/transaction/ProxyBackendTransactionManager.java
      • proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/ProxySQLExecutorTest.java
      • proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/StandardDatabaseProxyConnectorTest.java
      • proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/transaction/DeferredMetaDataRefreshContextTest.java
      • proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/transaction/ProxyBackendTransactionManagerTest.java
      • test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/cases/metadata/MySQLDDLMetaDataRefreshTestCase.java
      • test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/cases/metadata/PostgreSQLDDLMetaDataRefreshTestCase.java
    • RELEASE-NOTES.md and test/e2e/operation/transaction/src/test/resources/env/e2e-env.properties are not governed by the configured Java Spotless or Checkstyle scopes.
  • Focused verification passed: 100 unit tests, zero failures/errors; the transaction E2E module compiled 61 test sources.
  • Docker-backed E2E execution was not run; it is not outcome-sensitive to the code-proven blockers.
  • CI/Actions were not reviewed. This is a code-scope result only; mandatory local style verification is complete.

@rishi-rana

Copy link
Copy Markdown
Contributor Author

Thanks, all three addressed in 3c86b00.

Scope of this revision

This revision changes behaviour for one case only: table DDL executed inside a transaction on PostgreSQL. CREATE TABLE, ALTER TABLE, DROP TABLE and RENAME TABLE are now permitted there and their meta data refresh is deferred to the end of the transaction.

Everything else is unchanged from master:

  • PostgreSQL schema DDL and view DDL in a transaction are still rejected with TableModifyInTransactionException.
  • Every other dialect keeps its existing permission rules and refreshes meta data immediately, because isSupportTransactionalDDL is false for all of them.
  • Behaviour outside a transaction is untouched for every dialect.

2. Immediate refresh for implicit-commit dialects

DialectTransactionOption gains isSupportTransactionalDDL, set only for PostgreSQL. The refresh is deferred only when that capability is set, so MySQL, MariaDB, Oracle, H2, SQL Server and Firebird refresh immediately as before and their meta data does not go stale while the logical transaction is still open.

MySQLDDLMetaDataRefreshTestCase now asserts from a second connection that the altered column is in meta data while the first connection's transaction is still open, and again after its rollback.

1. Object type and identifier semantics

Deferral is restricted to table DDL. ProxySQLExecutor permits CREATE TABLE, ALTER TABLE, DROP TABLE and RENAME TABLE in a transaction when isSupportTransactionalDDL is set, and PostgreSQL keeps isSupportMetaDataRefreshInTransaction as false, so schema DDL and view DDL remain rejected in a transaction exactly as before this PR. Those statements therefore never reach the deferred context, which is why it reloads tables only.

Identifiers are preserved: the deferred context stores the parsed IdentifierValue of each table and calls ContextManager#reloadTable(ShardingSphereDatabase, String, IdentifierValue), so a quoted mixed-case table is reloaded as the quoted identifier rather than an unquoted one. DeferredMetaDataRefreshContextTest#assertReloadKeepsQuotedIdentifier covers this, and the connector test below uses a quoted table name.

3. Reachable DDL path and test standards

assertExecuteDefersMetaDataRefreshForTransactionalDDLDialect builds a real AlterTableStatement through CommonSQLStatementContext, so PushDownMetaDataRefreshEngine#isNeedRefresh returns true from production logic rather than from a stub, and the table identifiers come from the real TablesContext. The table name is quoted, so the test also covers the identifier case above.

The remaining construction mock is DatabaseTypeRegistry, used to supply the DialectTransactionOption under test. PostgreSQL's DialectDatabaseMetaData SPI is not on proxy/backend/core's test classpath, so the dialect capability is isolated at that boundary rather than by adding a module dependency for the test; ProxySQLExecutorTest isolates the same collaborator the same way.

times(1) is replaced with plain verify.

Verification

  • ./mvnw -pl proxy/backend/core,database/connector/dialect/postgresql test - 593 tests, 0 failures.
  • Transaction E2E on mysql:5.7 - passed.
  • Transaction E2E on postgres:12-alpine - passed.
  • spotless:check and checkstyle:check -Pcheck across all 11 touched modules - 0 violations; apache-rat:check -Pcheck - passed.

On the intended scope

Two questions, since both go beyond the reported case and I would rather agree the boundary than assume it.

Should the deferral eventually cover the remaining metadata-changing statements rather than table DDL alone? Doing so needs a deferred representation carrying object type, and a view-level reload on ContextManager, which is why this revision stops at tables.

Should other backends with transactional DDL opt in as well? SQL Server looks like the notable case: it permits metadata-changing DDL in a transaction today through isSupportMetaDataRefreshInTransaction, and its DDL is transactional, so the stale meta data described in #35166 appears to apply to it as it did to PostgreSQL. openGauss rejects such DDL in a transaction today, so it is unaffected either way. I left isSupportTransactionalDDL as false for both rather than change dialects the issue did not report, but I am happy to set it where you think it belongs, in this PR or a follow-up.

@rishi-rana

rishi-rana commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor Author

CI status note, updated after the latest run.

All checks pass on cfbefd6f88e856b80fbc6b19a29d04237e918567.

Two earlier red checks on this pull request turned out to be unrelated to it, recorded here in case anyone reads back through the history:

  • E2E - SQL (Stage 2) (proxy, Cluster, MySQL, db_tbl_sql_federation) failed with Unsupported SQL operation: MySQL BIN function while the federation E2E cases still called bin(...). That inconsistency was fixed upstream and both federation legs now pass.
  • E2E - pipeline on mysql:5.7 timed out in IndexesMigrationE2EIT.assertNoUniqueKeyMigrationSuccess, with the migration importer losing its JDBC statement while ZooKeeper dropped its connection. It passed on a re-run of the identical tree, so it looks like an intermittent failure in that suite.

@linghengqian linghengqian left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have opened #39913 .

@rishi-rana
rishi-rana force-pushed the defer-metadata-refresh-in-transaction branch 2 times, most recently from 9c464ab to cfbefd6 Compare September 21, 2026 22:25

@terrymanu terrymanu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Result

Review Result: Not Mergeable

Feedback Mode: Needs Discussion

Blocking Issues: 2

The PR changes a published transaction limitation without a settled support boundary, and the new dialect gate also affects a documented mixed-database path.

Blocking Issues

  1. Agree on the PostgreSQL transaction DDL contract.
    Evidence: The maintained LOCAL and XA limitations say Proxy rejects metadata-changing PostgreSQL DDL in transactions. This PR permits four table DDL types, while its release note describes DDL more broadly.
    Impact: Users receive conflicting guidance about which DDL is supported in LOCAL and XA transactions.
    Discussion Needed: Confirm the exact supported statement and transaction types, then align the published contract with that decision.

  2. Resolve the PostgreSQL-protocol/MySQL-storage boundary.
    Evidence: DB Gateway documents PostgreSQL protocol over MySQL storage. Both the permission gate and deferral decision use the statement dialect, although routing identifies the physical storage dialect separately. MySQL 5.7 implicitly commits ALTER TABLE.
    Impact: A PostgreSQL-protocol transaction routed to MySQL can commit table DDL physically while Proxy defers its metadata refresh until the logical transaction ends. Other sessions can see stale metadata. The new MySQL E2E case covers a MySQL-protocol session, so it does not exercise this path.
    Discussion Needed: Decide whether transactional DDL support is limited by the routed storage type, including mixed routes, and define the required metadata timing for that boundary.

Coverage

  • Public PR #39882, Code Correctness Review; effective head cfbefd6f88e856b80fbc6b19a29d04237e918567, base 7ea8b8ce0fbe42472b185a4f45abf84ff278547f. GitHub’s authoritative 27-file list was accounted for using an exact-head source snapshot.
  • Reviewed the dialect-option changes; Proxy permission, execution, deferred queue, commit and rollback paths; unit and E2E tests; E2E registration; and release note. Rechecked the earlier statement-replay, direct-MySQL, and quoted-identifier objections. Root-cause, contract/blast-radius, test/runtime, and final convergence passes found no further independent blocker.
  • Local style verification: ./mvnw -pl database/connector/core,database/connector/dialect/firebird,database/connector/dialect/h2,database/connector/dialect/mariadb,database/connector/dialect/mysql,database/connector/dialect/opengauss,database/connector/dialect/oracle,database/connector/dialect/postgresql,database/connector/dialect/sqlserver,proxy/backend/core,test/e2e/operation/transaction spotless:check checkstyle:check -Pcheck -T1C exited 0. Spotless selected Java files in all 11 modules; Checkstyle reported zero violations in each. The covered 25 PR-impact Java files were:
    • database/connector/core: DialectDatabaseMetaData.java, DialectTransactionOption.java.
    • database/connector/dialect: FirebirdDatabaseMetaData.java, H2DatabaseMetaData.java, MariaDBDatabaseMetaData.java, MySQLDatabaseMetaData.java, OpenGaussDatabaseMetaData.java, OracleDatabaseMetaData.java, PostgreSQLDatabaseMetaData.java, PostgreSQLDatabaseMetaDataTest.java, SQLServerDatabaseMetaData.java.
    • proxy/backend/core production: ProxyDatabaseConnectionManager.java, ProxySQLExecutor.java, StandardDatabaseProxyConnector.java, DeferredMetaDataRefreshContext.java, ProxyBackendTransactionManager.java.
    • proxy/backend/core tests: ProxySQLExecutorTest.java, StandardDatabaseProxyConnectorTest.java, DeferredMetaDataRefreshContextTest.java, ProxyBackendTransactionManagerTest.java, BeginTransactionProxyBackendHandlerTest.java, CommitProxyBackendHandlerTest.java, SetAutoCommitProxyBackendHandlerTest.java.
    • test/e2e/operation/transaction: MySQLDDLMetaDataRefreshTestCase.java, PostgreSQLDDLMetaDataRefreshTestCase.java.
  • Checkstyle and Spotless are Not Applicable to RELEASE-NOTES.md and test/e2e/operation/transaction/src/test/resources/env/e2e-env.properties under the configured Java and workflow-file scopes.
  • Focused reactor tests passed: 101 tests, zero failures. An initial non-reactor compile used a stale locally installed core artifact; the corrected -am run passed. Docker-backed E2E was not run. This is a code-scope result; CI was not reviewed.
  • Jev: the typesafe-ai skill was not used for this deep code review. Jev MCP was not called because quota or balance was unconfirmed: 0 calls and judgments, no effect on routing, prioritization, conclusions, or plan. Efficiency cannot be measured accurately; problems: none found.

@rishi-rana

Copy link
Copy Markdown
Contributor Author

Both points are fair. Here is the contract I propose, so the boundary is agreed before I change anything further.

1. Supported statements and transaction types

Proposed contract:

  • Permitted inside a transaction: CREATE TABLE, ALTER TABLE, DROP TABLE and RENAME TABLE.
  • Transaction types: LOCAL and XA.
  • Still rejected with SQLSTATE 0A000, unchanged from today: schema DDL, view DDL, index DDL, and any other metadata-changing statement.
  • Backends: PostgreSQL only. openGauss keeps the current restriction because it does not set the new capability.

If that is the boundary you want, I will align the published contract with it:

  • docs/document/content/features/transaction/limitations.en.md and limitations.cn.md: narrow the LOCAL bullet so it states that only the four table DDL statements are supported for PostgreSQL and that other metadata-changing DDL is still rejected, and update the XA bullet that refers to it.
  • RELEASE-NOTES.md: change "DDL" to "table DDL" so the entry matches the code.

One question inside this point. Should the contract be written as "PostgreSQL" or as "backends whose DDL is transactional"? SQL Server is the case that decides the wording: it permits metadata-changing DDL in a transaction today through isSupportMetaDataRefreshInTransaction, and its DDL is transactional, so the stale meta data in #35166 appears to apply to it as well. I have left isSupportTransactionalDDL as false for it in this PR, and I am happy either to keep the contract PostgreSQL-only or to include SQL Server here or in a follow-up, whichever you prefer.

2. Protocol dialect against routed storage dialect

You are right that both decisions currently read the statement dialect, and that this is wrong for DB Gateway. Proposed rule:

  • Resolve isSupportTransactionalDDL from the routed storage unit types, through database.getResourceMetaData().getStorageUnits() keyed by each route unit's actual data source name, in the same way routing already resolves the storage dialect.
  • Permit and defer only when every routed storage unit is a backend whose DDL is transactional.
  • If any routed storage unit is not, including a mixed route, behave exactly as today: the permission decision uses the existing options and the refresh happens immediately. A PostgreSQL-protocol session routed to MySQL storage therefore behaves as a MySQL session does.
  • Use that same resolution for the permission gate and the deferral decision, so the two cannot disagree about a given statement.

ProxySQLExecutor#checkExecutePrerequisites is called after generateExecutionContext, so the route context is already available at that point and only its signature needs to widen.

For coverage I would add unit tests for a PostgreSQL-protocol session routed to MySQL storage, and for a mixed route, asserting that DDL is rejected rather than deferred in both.

Please confirm or correct these two, and I will implement and update the documentation accordingly.

@terrymanu terrymanu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Result

Review Result: Not Mergeable

Feedback Mode: Needs Discussion

Blocking Issues: 2

PR #39882 enables a transaction behavior whose supported scope is still unsettled, and its dialect decision can disagree with the routed storage.

Blocking Issues

  1. Agree on the transactional DDL contract.

    Evidence: The maintained LOCAL and XA limitations say Proxy rejects metadata-changing PostgreSQL DDL in transactions. The PR permits four table DDL statement types; its non-XA branch does not exclude BASE. The release note says “DDL” broadly. The author has proposed a narrower contract and requested confirmation.

    Impact: Code and published guidance disagree about which statements and transaction types users can rely on.

    Discussion Needed: Confirm the supported statements, transaction types, and backend scope, then align the implementation and published contract.

  2. Resolve the protocol dialect versus routed storage dialect boundary.

    Evidence: DB Gateway documents PostgreSQL protocol over MySQL storage. Routing resolves physical storage type separately, while both the permission check and deferral decision use the statement dialect. MySQL 5.7 implicitly commits ALTER TABLE; the queued refresh runs only when Proxy later commits or rolls back.

    Impact: In a PostgreSQL-protocol LOCAL transaction routed to MySQL, storage can expose the DDL while Proxy still has stale metadata. The new MySQL E2E case uses a MySQL-protocol session and does not cover this route.

    Discussion Needed: Define transactional DDL support and refresh timing using the routed storage types, including mixed routes, so permission and deferral follow one agreed rule.

Coverage

  • Public PR #39882, Code Correctness Review. Effective head cfbefd6f88e856b80fbc6b19a29d04237e918567; base 7ea8b8ce0fbe42472b185a4f45abf84ff278547f. GitHub’s authoritative 27-file list was accounted for against an exact-head source snapshot. The head was rechecked after verification. A local PR ref was unavailable, so no local triple-dot comparison was made.
  • Reviewed the dialect option and eight dialect call sites; Proxy permission, execution, queue, commit and rollback paths; unit and E2E tests and registration; release note; and maintained transaction and DB Gateway contracts. Root-cause, contract/blast-radius, tests/runtime, and final convergence passes found no further independent blocker or outcome-sensitive evidence gap. Earlier statement-replay, direct-MySQL, and quoted-identifier objections were rechecked against the current implementation.
  • Local style verification: ./mvnw -pl database/connector/core,database/connector/dialect/firebird,database/connector/dialect/h2,database/connector/dialect/mariadb,database/connector/dialect/mysql,database/connector/dialect/opengauss,database/connector/dialect/oracle,database/connector/dialect/postgresql,database/connector/dialect/sqlserver,proxy/backend/core,test/e2e/operation/transaction spotless:check checkstyle:check -Pcheck -T1C exited 0. All 11 module Java scopes were selected by Spotless; all 11 Checkstyle summaries reported zero violations.
  • Both checks covered all 25 PR-impact Java files: database/connector/core — DialectDatabaseMetaData.java, DialectTransactionOption.java; dialect modules — FirebirdDatabaseMetaData.java, H2DatabaseMetaData.java, MariaDBDatabaseMetaData.java, MySQLDatabaseMetaData.java, OpenGaussDatabaseMetaData.java, OracleDatabaseMetaData.java, PostgreSQLDatabaseMetaData.java, PostgreSQLDatabaseMetaDataTest.java, SQLServerDatabaseMetaData.java; proxy/backend/core production — ProxyDatabaseConnectionManager.java, ProxySQLExecutor.java, StandardDatabaseProxyConnector.java, DeferredMetaDataRefreshContext.java, ProxyBackendTransactionManager.java; its tests — ProxySQLExecutorTest.java, StandardDatabaseProxyConnectorTest.java, DeferredMetaDataRefreshContextTest.java, ProxyBackendTransactionManagerTest.java, BeginTransactionProxyBackendHandlerTest.java, CommitProxyBackendHandlerTest.java, SetAutoCommitProxyBackendHandlerTest.java; transaction E2E — MySQLDDLMetaDataRefreshTestCase.java, PostgreSQLDDLMetaDataRefreshTestCase.java.
  • Checkstyle and Spotless are Not Applicable to RELEASE-NOTES.md and test/e2e/operation/transaction/src/test/resources/env/e2e-env.properties under the configured Java, POM, and workflow-file scopes. Runtime and Docker E2E tests were not run. This is a code-scope result; CI was not reviewed.
  • Jev: the typesafe-ai skill was not used because this deep code review was not a bounded judgment; it provided no guidance. Jev MCP was not called: 0 calls and judgments, with no effect on routing, prioritization, conclusions, or plan. Efficiency change cannot be measured accurately; problems: none found.

@rishi-rana

Copy link
Copy Markdown
Contributor Author

Thanks. Both points are addressed in b6cb07f.

1. Transactional DDL contract

The contract is now:

  • Permitted inside a transaction: CREATE TABLE, ALTER TABLE, DROP TABLE and RENAME TABLE.
  • Transaction types: LOCAL and XA. BASE is excluded. You were right that the non-XA branch did not exclude it, so it inherited table DDL support from the local branch; it now has its own branch reproducing the previous behaviour.
  • Still rejected with SQLSTATE 0A000: schema DDL, view DDL, index DDL, and every other metadata-changing statement.
  • Backends: PostgreSQL only; openGauss does not set the new capability.

limitations.en.md and limitations.cn.md are updated for LOCAL, XA and BASE, and the release note now says "table DDL".

On backend scope: I have left isSupportTransactionalDDL as false for SQL Server. It permits metadata-changing DDL in a transaction today and its DDL is transactional, so #35166 appears to apply to it, but I would rather you decide whether that belongs here or in a follow-up than change a dialect the issue did not report.

2. Protocol dialect against routed storage dialect

The capability is now resolved from the storage units the statement is routed to, requiring every routed unit to keep DDL transactional. Mixed routes and any implicit-commit storage fall back to the previous behaviour, so a PostgreSQL-protocol session routed to MySQL behaves as a MySQL session does. One predicate, isDeferrableTableDDL, feeds both the permission check and the deferral, so the two cannot disagree. New unit scenarios cover PostgreSQL protocol with non-transactional storage in LOCAL and XA, and PostgreSQL in BASE.

A correctness problem this surfaced

While covering CREATE TABLE I found that ContextManager#reloadTable cannot register a new table. With no data node, SchemaMetaDataUtils#addOneActualTableDataNode falls back to the first storage unit, so a table created on another unit is not found and persistTable drops it instead; it also bypasses MetaDataManagerPersistService#createTable, so a single table is never registered in the single-rule configuration.

The deferred tables are therefore reconciled through a new ContextManager#reconcileTable, which uses the existing loader and manager service to create, alter or drop each table according to its committed state. A reconcile problem is logged rather than propagated, so it can no longer surface as a commit failure after the transaction has committed. A rollback now discards the deferred tables without reconciling, since deferral only happens when the DDL was transactional and therefore undone.

A limitation worth recording

A statement cannot reference a table created earlier in the same transaction: BEGIN; CREATE TABLE t (...); ALTER TABLE t ...; fails on the second statement, because the deferred meta data of t is only applied when the transaction ends. This is inherent to deferring the refresh, and it means the create-then-rename sequence from your earlier review is not reachable. It is documented in both limitations files.

Verification

  • ./mvnw -pl mode/core,proxy/backend/core,database/connector/dialect/postgresql test - 596 tests, 0 failures.
  • Transaction E2E on postgres:12-alpine - passed for LOCAL, XA with Atomikos and XA with Narayana, including a new case that creates a table inside a transaction and asserts it is present in meta data after commit.
  • Transaction E2E on mysql:5.7 - passed.
  • spotless:check and checkstyle:check -Pcheck across all 12 touched modules - 0 violations; apache-rat:check -Pcheck - passed.

@terrymanu terrymanu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Result

Review Result: Not Mergeable

Feedback Mode: Needs Discussion

Blocking Issues: 4

The latest revision fixes the earlier protocol-versus-storage decision and BASE scope problems. However, two metadata correctness defects, one written coding-standard violation, and an unsettled support contract remain.

Blocking Issues

  1. [P1] Metadata deletion uses the original identifier instead of its canonical name.

    Evidence: ContextManager.java:294 passes tableName.getValue() directly to the deletion service. The persistence service deletes the node using that name. PostgreSQL 12 documentation specifies that unquoted identifiers are folded to lowercase. An isolated verification confirmed that the deletion targets /tables/FOO, while the existing record is /tables/foo.

    Impact: After BEGIN; DROP TABLE FOO; COMMIT; physically drops foo, its persisted metadata remains. If a separate "FOO" table exists, the operation can also delete that other table’s metadata.

    Discussion Needed: Deletion must follow the canonical storage and metadata name while preserving quoted-identifier distinctions. The previous head’s refresh path also contained this problem; it was missed in the previous public review.

  2. [P1] Reconciling every table against the first route changes single-table storage ownership.

    Evidence: StandardDatabaseProxyConnector.java:296 records the same data source for every table. The loader called by the new reconciler adds that node to the shared single-table rule. In isolated verification, the configuration changed from [ds_1.public.b] to [ds_1.public.b, ds_0.public.b].

    Impact: When a and b reside on different PostgreSQL storage units, SAVEPOINT s; DROP TABLE IF EXISTS a,b; ROLLBACK TO s; COMMIT; reconciles both surviving tables and adds an incorrect data node for the second table.

    Discussion Needed: Reconciliation after a savepoint rollback must preserve each table’s original storage ownership. This defect was introduced by the latest commit’s new reconcileTable loading path.

  3. The new transactional DDL support boundary still requires a project decision.

    Evidence: The original issue reports the problem after manually removing the restriction. The author subsequently requested confirmation of the support contract. The latest limitations documentation publishes LOCAL/XA support for four table DDL categories and adds a restriction preventing subsequent statements from referencing a table created in the same transaction. The complete public discussion contains no maintainer decision accepting that full boundary.

    Impact: Documentation and implementation now agree, but the new support scope and usage restrictions remain a contributor-proposed contract.

    Discussion Needed: Explicitly accept or adjust the statement categories, transaction types, backend scope, and availability of newly created tables within the same transaction. Updating documentation does not itself establish project acceptance.

  4. [P2] The added method layout violates the written private-helper ordering rule.

    Evidence: CODE_OF_CONDUCT.md:48 requires private helpers to immediately follow their caller and appear in call order. The added reconcileTable separates reloadTable from persistTable; the connector’s two decision helpers appear in the reverse of their call order; and the new E2E class declares its third phase first.

    Impact: The candidate does not satisfy a repository rule that requires manual verification. Passing Checkstyle and Spotless does not establish compliance with this rule.

    Discussion Needed: The merge candidate must still satisfy the written declaration-order requirements.

Coverage

  • Public PR #39882; Code Correctness Review. This is a code-scope result; CI was not reviewed. Effective head: b6cb07f42e456c1de4c7b41c9150a046d16b51a8; base: 7ea8b8ce0fbe42472b185a4f45abf84ff278547f; merge-base: 101c3d56ccd7ee3c4a390a8f37550bed58a4751c. GitHub’s authoritative 30-file list matched the public triple-dot comparison. An exact-head snapshot was used, and the final head recheck confirmed no change. There was no local code delta.
  • Reviewed transaction capabilities and every constructor call site; Proxy permission and actual-storage routing; commit, rollback, and savepoints; metadata reconciliation and persistence; single-table rules; unit/E2E tests and registration; both limitations documents; and release notes. The PostgreSQL post-commit refresh objective was assessed against #35166, alongside the other affected dialects and openGauss restrictions. Root-cause, contract-impact, test/runtime, and final convergence passes were completed, with no unresolved evidence gaps.
  • Local style command: ./mvnw -B -pl database/connector/core,database/connector/dialect/firebird,database/connector/dialect/h2,database/connector/dialect/mariadb,database/connector/dialect/mysql,database/connector/dialect/opengauss,database/connector/dialect/oracle,database/connector/dialect/postgresql,database/connector/dialect/sqlserver,mode/core,proxy/backend/core,test/e2e/operation/transaction spotless:check checkstyle:check -Pcheck -T1C; exit code 0.
  • Both checks covered all 26 changed Java files:
    • database/connector/core: DialectDatabaseMetaData.java, DialectTransactionOption.java.
    • Dialect modules: FirebirdDatabaseMetaData.java, H2DatabaseMetaData.java, MariaDBDatabaseMetaData.java, MySQLDatabaseMetaData.java, OpenGaussDatabaseMetaData.java, OracleDatabaseMetaData.java, PostgreSQLDatabaseMetaData.java, PostgreSQLDatabaseMetaDataTest.java, SQLServerDatabaseMetaData.java.
    • mode/core: ContextManager.java.
    • proxy/backend/core: ProxyDatabaseConnectionManager.java, ProxySQLExecutor.java, StandardDatabaseProxyConnector.java, DeferredMetaDataRefreshContext.java, ProxyBackendTransactionManager.java; and ProxySQLExecutorTest.java, StandardDatabaseProxyConnectorTest.java, DeferredMetaDataRefreshContextTest.java, ProxyBackendTransactionManagerTest.java, BeginTransactionProxyBackendHandlerTest.java, CommitProxyBackendHandlerTest.java, SetAutoCommitProxyBackendHandlerTest.java.
    • Transaction E2E: MySQLDDLMetaDataRefreshTestCase.java, PostgreSQLDDLMetaDataRefreshTestCase.java.
  • Checkstyle also selected and passed test/e2e/operation/transaction/src/test/resources/env/e2e-env.properties. Spotless is Not Applicable to that properties file. Both tools are Not Applicable to RELEASE-NOTES.md and the two limitations.*.md files, based on the configured Java/POM/workflow formatting scopes and Checkstyle file extensions.
  • Six focused test classes ran against the exact-source reactor: 134 tests, 0 failures/errors, exit code 0. One -am run ensured that cross-module constructors and behavior came from current source. Both isolated verifications exited 0, confirming the incorrect deletion key and incorrect data-node registration respectively. Docker E2E was not run.
  • Jev: the typesafe-ai skill was not used and provided no guidance; this deep, multi-step code review remained in Codex. Jev MCP calls and judgments: 0. Jev did not change routing, prioritization, conclusions, or the plan. Efficiency changes cannot be measured accurately; problems: none found.

@rishi-rana

Copy link
Copy Markdown
Contributor Author

Thanks, both correctness findings are confirmed and addressed in 709aaf7.

1. Deletion key

ContextManager.reconcileTable's drop branch now resolves the table through TableRefreshUtils.getTableLoadCandidateName, the same canonical-storage-name path the create/alter branches already use, instead of the raw parsed identifier. Added ContextManagerTest.assertReconcileTableDropsUsingCanonicalStorageName, which fails against the previous code with the exact mismatch you found (dropTables called with FOO_TBL instead of foo_tbl).

2. Data source attribution

Each deferred table is now matched to its own RouteUnit by logic table name (RouteUnit.getLogicTableNames()), falling back to the first route unit only if none matches. This required changing DeferredMetaDataRefreshContext.add from taking a batch of tables with one shared data source to one table at a time, so each gets its own. Added StandardDatabaseProxyConnectorTest.assertExecuteDefersMetaDataRefreshUsingEachTableOwnRouteUnit, which reproduces your [ds_1.public.b] → [ds_1.public.b, ds_0.public.b] scenario and fails against the previous code for the same reason.

4. Declaration order

  • ContextManager: reconcileTable moved after persistTable, restoring adjacency with reloadTable.
  • StandardDatabaseProxyConnector: isDeferrableTableDDL and isCurrentTransactionCommitRequired swapped to match their call order in doExecute.
  • PostgreSQLDDLMetaDataRefreshTestCase: the third phase moved to be declared third, matching executeTest's call order.

Verification: 112 unit tests pass across mode/core and proxy/backend/core; test/e2e/operation/transaction test-compiles; spotless:check checkstyle:check -Pcheck reports zero violations on all three modules.

3. Support contract

I don't have authority to settle this myself, so I'd like explicit sign-off before treating it as decided. The contract as it currently stands in docs/document/content/features/transaction/limitations.en.md and in this PR's code is:

  • Permitted inside a transaction: CREATE TABLE, ALTER TABLE, DROP TABLE, RENAME TABLE.
  • Transaction types: LOCAL and XA. BASE is excluded.
  • Backend scope: routed storage units that report isSupportTransactionalDDL(), checked per route unit.
  • A table created earlier in the same transaction is not visible to a later statement in that transaction (deferred refresh only runs at commit).

@terrymanu could you confirm whether this is the scope you're willing to accept, or whether any of the four points above should be narrowed, widened, or deferred to a separate PR? I'll update the docs and/or code to match whatever you decide.

@rishi-rana
rishi-rana requested a review from terrymanu October 4, 2026 01:58

@terrymanu terrymanu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Result

Review Result: Not Mergeable

Feedback Mode: Needs Discussion

Blocking Issues: 4

The canonical-name and per-table routing fixes are confirmed. Two metadata defects, written coding-standard violations, and an unsettled support contract remain.

Blocking Issues

  1. [P1] BASE transactions can discard refreshes for already committed DDL.

    Evidence: ProxySQLExecutor.java:156 permits metadata-changing DDL under MySQL protocol in BASE. The deferral condition queues it when storage is PostgreSQL, without excluding BASE. Seata 2.6.0’s PlainExecutor executes this DDL directly.

    Impact: With MySQL protocol, PostgreSQL storage, and Seata BASE, BEGIN; ALTER TABLE t ADD COLUMN c INT; ROLLBACK; physically commits the column, then discards its queued refresh. ShardingSphere metadata remains stale. An isolated probe confirmed permission, parser acceptance, unchanged SQL translation, and Seata’s plain execution path.

    Discussion Needed: The BASE exclusion must cover refresh timing as well as permission; storage capability alone does not establish transactional DDL execution.

  2. [P2] Savepoint rollback can leave a nonexistent table registered in cluster routing.

    Evidence: ContextManager.java:302 calls the creation loader before checking table absence. The loader adds a node to the live SingleRule. Cluster deletion of a never-persisted table produces no event to remove that node.

    Impact: In Cluster/ZooKeeper mode with wildcard SINGLE configuration and multiple storage units, BEGIN; SAVEPOINT s; CREATE TABLE t (id INT); ROLLBACK TO s; COMMIT; leaves a routing entry for absent t. A subsequent CREATE fails with TableExistsException. An isolated current-source probe confirmed both effects. Full rollback and standalone mode do not exhibit this path.

    Discussion Needed: Reconciliation of an absent table must leave no temporary routing state behind.

  3. [P2] The candidate still violates written coding standards.

    Evidence: CODE_OF_CONDUCT.md governs class finality, private-helper order, and wrapping. Current violations include:

    • DeferredMetaDataRefreshContextTest.java:33: the new concrete class is not final.
    • PostgreSQLDDLMetaDataRefreshTestCase.java:83: its unique helper awaitQueryable is separated from its caller until line 125.
    • Unnecessary wrapping in ProxySQLExecutor.java:153, ContextManagerTest.java:392, MySQLDDLMetaDataRefreshTestCase.java:73, and PostgreSQLDDLMetaDataRefreshTestCase.java:109,126; reconstructed lines are 183–190 characters.

    Impact: Passing Spotless and Checkstyle does not establish compliance with these manually enforced rules.

    Discussion Needed: The final candidate must satisfy the written standards alongside the accepted behavior.

  4. The transactional DDL support commitment still requires maintainer acceptance.

    Evidence: The author explicitly requests sign-off on the four statement categories, LOCAL/XA scope, routed-storage capability, and inability to reference newly created tables before commit. The complete discussion contains no subsequent acceptance.

    Impact: The updated documentation publishes a contributor-proposed support boundary and usage restriction.

    Discussion Needed: Accept or adjust that boundary before treating it as the project contract.

The two functional defects already existed at the previously reviewed head and were missed then. The latest commit introduces the remaining unique-helper ordering violation; the other cited standards violations predate it.

Coverage

  • Public PR #39882, Code Correctness Review. Effective head: 709aaf76cd776ac54777313d55599c1b07f8f607; base: 7ea8b8ce0fbe42472b185a4f45abf84ff278547f; merge-base: 101c3d56ccd7ee3c4a390a8f37550bed58a4751c. GitHub’s authoritative 31-file list matched its triple-dot comparison. The exact-head snapshot and final head recheck matched; no local code delta was included.
  • Reviewed dialect capabilities, routed permissions, LOCAL/XA/BASE lifecycle, savepoints, metadata persistence and routing, unit/E2E entry paths, registration, documentation, and release notes. Basis: #35166 and maintained transaction, Gateway, and Seata contracts. All three discovery lenses and final convergence completed; no unresolved decisive evidence gaps.
  • Local style verification: ./mvnw -B -pl database/connector/core,database/connector/dialect/firebird,database/connector/dialect/h2,database/connector/dialect/mariadb,database/connector/dialect/mysql,database/connector/dialect/opengauss,database/connector/dialect/oracle,database/connector/dialect/postgresql,database/connector/dialect/sqlserver,mode/core,proxy/backend/core,test/e2e/operation/transaction spotless:check checkstyle:check -Pcheck -T1C exited 0. Both checks selected all 27 changed Java files:
    • Connector core: DialectDatabaseMetaData, DialectTransactionOption.
    • Dialects: FirebirdDatabaseMetaData, H2DatabaseMetaData, MariaDBDatabaseMetaData, MySQLDatabaseMetaData, OpenGaussDatabaseMetaData, OracleDatabaseMetaData, PostgreSQLDatabaseMetaData, PostgreSQLDatabaseMetaDataTest, SQLServerDatabaseMetaData.
    • Mode core: ContextManager, ContextManagerTest.
    • Proxy backend: ProxyDatabaseConnectionManager, ProxySQLExecutor, StandardDatabaseProxyConnector, DeferredMetaDataRefreshContext, ProxyBackendTransactionManager; and ProxySQLExecutorTest, StandardDatabaseProxyConnectorTest, DeferredMetaDataRefreshContextTest, ProxyBackendTransactionManagerTest, BeginTransactionProxyBackendHandlerTest, CommitProxyBackendHandlerTest, SetAutoCommitProxyBackendHandlerTest.
    • Transaction E2E: MySQLDDLMetaDataRefreshTestCase, PostgreSQLDDLMetaDataRefreshTestCase.
  • Checkstyle also selected and passed test/e2e/operation/transaction/src/test/resources/env/e2e-env.properties; Spotless is Not Applicable to it. Both checks are Not Applicable to RELEASE-NOTES.md and both limitations.*.md files under the configured scopes.
  • Six focused test classes passed against the source reactor: 138 tests, 0 failures/errors, exit 0. Both isolated Java probes exited 0; physical metadata absence and external persistence were mocked in the cluster probe. ./mvnw -B apache-rat:check -Pcheck -T1C exited 0. Docker E2E was not run.
  • This is a code-scope result; CI was not reviewed.
  • Jev: skill unused; MCP calls/judgments 0 because this required deep, multi-step source analysis. No effect on routing, prioritization, conclusions, or plan. Efficiency changes cannot be measured accurately; problems: none found.

@rishi-rana

Copy link
Copy Markdown
Contributor Author

Thanks, both correctness findings confirmed and addressed in b65352b, along with the style findings.

  1. ProxySQLExecutor.java:156 / StandardDatabaseProxyConnector.java:295-301 — the deferral condition now checks transaction type via isInDeferrableTransaction() and excludes BASE. A BASE transaction's DDL now refreshes synchronously instead of being queued and discarded on rollback.
  2. ContextManager.java:302 — when reconcileTable determines the table does not exist, it now removes the speculative single-table route registration the loader adds before dropping, instead of leaving it behind.
  3. DeferredMetaDataRefreshContextTest.java:33 — class declared final.
    PostgreSQLDDLMetaDataRefreshTestCase.java:83 — awaitQueryable moved to immediately follow assertCreatedTableReconciledAfterCommit.
    ProxySQLExecutor.java:153, ContextManagerTest.java:392, MySQLDDLMetaDataRefreshTestCase.java:73, PostgreSQLDDLMetaDataRefreshTestCase.java:109,126 — unwrapped.

Verification: 921 tests pass across the full mode/core and proxy/backend/core modules (not just the changed classes); test/e2e/operation/transaction compiles; spotless:check checkstyle:check -Pcheck clean on all twelve modules.

  1. Still awaiting your sign-off on the support contract from the earlier comment.

@rishi-rana

rishi-rana commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Correction to my last comment's point 3: DeferredMetaDataRefreshContextTest.java:33 — class declared final.

CI failed after that push. checkstyle:check runs against the PR's merge ref, and a rule landed on master since this branch's base that explicitly forbids final on a class named *Test:

<module name="MatchXpath">
    <property name="query" value="//CLASS_DEF[./IDENT[ends-with(@text, 'Test')]]/MODIFIERS/FINAL" />
    <message key="matchxpath.match" value="Unit-test classes must not be declared final." />
</module>

That directly contradicts the finding I implemented. Reverted in 8ba4e56; verified against a worktree merging this branch onto current master before pushing. CheckStyle on the merge ref now passes.

@rishi-rana
rishi-rana requested a review from terrymanu October 5, 2026 23:22

@terrymanu terrymanu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Result

Review Result: Not Mergeable

Feedback Mode: Needs Discussion

Blocking Issues: 3

Two metadata defects remain, and the proposed transactional DDL support contract still needs maintainer acceptance.

Blocking Issues

  1. [P2] Committed DROP leaves obsolete explicit SINGLE configuration persisted.

    Evidence: ContextManager.java:307 removes the routing node before calling dropTables. The standalone persistence service then sees isNeedRefresh=false and skips persisting the changed SINGLE configuration. An isolated current-source probe confirmed this sequence.

    Impact: With an explicitly configured SINGLE table, BEGIN; DROP TABLE t; COMMIT; removes table metadata and live configuration, while persisted configuration retains ds.public.t. Reloading and exporting that configuration still produces LOAD SINGLE TABLE ds.public.t;.

    Discussion Needed: Reconciliation must preserve configuration persistence while cleaning up speculative routing. This defect was introduced by the latest cleanup commit, b65352b219f.

  2. [P2] Cross-schema DROP records every table under the first schema.

    Evidence: StandardDatabaseProxyConnector.java:296–299 computes one schema for the entire statement. PostgreSQL permits multiple schema-qualified DROP targets. The parser, binder, routing and rewriting paths preserve those distinct schemas; an isolated public-connector probe confirmed the incorrect deferred records.

    Impact: On one PostgreSQL storage unit, BEGIN; DROP TABLE schema_a.a, schema_b.b; COMMIT; reconciles schema_a.a and schema_a.b, leaving metadata for the physically dropped schema_b.b.

    Discussion Needed: The proposed table-DDL support must preserve each target’s schema. The immediate refresher has a similar pre-existing limitation, but this PR newly permits the transactional statement and owns these deferred records. This defect predates the latest fixes and was missed in earlier reviews.

  3. The transactional DDL support commitment remains unsettled.

    Evidence: Issue #35166 reproduces the problem after manually removing the existing restriction. The author explicitly requests maintainer sign-off and still reports it as pending. The complete public discussion contains no subsequent acceptance.

    Impact: The updated limitations publish a new support boundary and a restriction on referencing tables created earlier in the same transaction.

    Discussion Needed: Accept or adjust the four table-DDL categories, LOCAL/XA scope, routed-storage capability requirement, and visibility of newly created tables before commit.

Coverage

  • Public PR #39882; Code Correctness Review. Effective head: 8ba4e568e0aceaae7afb4e9a8be9406305b1cfc5; base: 7ea8b8ce0fbe42472b185a4f45abf84ff278547f; merge-base: 101c3d56ccd7ee3c4a390a8f37550bed58a4751c. GitHub’s authoritative 31-file list matched the triple-dot API comparison. An exact-head snapshot was used; the final head remained unchanged. No local code delta was included.
  • Reviewed dialect capabilities and constructor callers; routed permissions; LOCAL/XA/BASE lifecycle; savepoints; metadata reconciliation, persistence and SINGLE routing; unit/E2E entry paths and registration; both limitations documents; release notes. Basis: #35166, maintained transaction restrictions, and PostgreSQL semantics. Root-cause, contract-impact, tests/runtime and convergence passes completed with no unresolved decisive evidence gaps.
  • Previous canonical-name, data-source attribution, BASE-deferral, wildcard savepoint-routing, wrapping and helper-order findings are fixed. The test-class finality finding is withdrawn: newer Checkstyle explicitly forbids final *Test classes.

Local style command, exit 0 for both checks:

./mvnw -B -pl database/connector/core,database/connector/dialect/firebird,database/connector/dialect/h2,database/connector/dialect/mariadb,database/connector/dialect/mysql,database/connector/dialect/opengauss,database/connector/dialect/oracle,database/connector/dialect/postgresql,database/connector/dialect/sqlserver,mode/core,proxy/backend/core,test/e2e/operation/transaction spotless:check checkstyle:check -Pcheck -T1C

Both checks selected all 27 changed Java files:

Owning module Covered files
database/connector/core DialectDatabaseMetaData.java, DialectTransactionOption.java
Connector dialect modules FirebirdDatabaseMetaData.java, H2DatabaseMetaData.java, MariaDBDatabaseMetaData.java, MySQLDatabaseMetaData.java, OpenGaussDatabaseMetaData.java, OracleDatabaseMetaData.java, PostgreSQLDatabaseMetaData.java, PostgreSQLDatabaseMetaDataTest.java, SQLServerDatabaseMetaData.java
mode/core ContextManager.java, ContextManagerTest.java
proxy/backend/core ProxyDatabaseConnectionManager.java, ProxySQLExecutor.java, StandardDatabaseProxyConnector.java, DeferredMetaDataRefreshContext.java, ProxyBackendTransactionManager.java, ProxySQLExecutorTest.java, StandardDatabaseProxyConnectorTest.java, DeferredMetaDataRefreshContextTest.java, ProxyBackendTransactionManagerTest.java, BeginTransactionProxyBackendHandlerTest.java, CommitProxyBackendHandlerTest.java, SetAutoCommitProxyBackendHandlerTest.java
test/e2e/operation/transaction MySQLDDLMetaDataRefreshTestCase.java, PostgreSQLDDLMetaDataRefreshTestCase.java
  • Checkstyle also selected and passed test/e2e/operation/transaction/src/test/resources/env/e2e-env.properties; Spotless is Not Applicable to properties. Both checks are Not Applicable to RELEASE-NOTES.md and both limitations.*.md files under the configured formatting scopes and Checkstyle extensions.
  • Exact-source reactor verification: 149 tests across nine focused classes, zero failures/errors, exit 0. One -am run ensured dependency freshness. Both isolated probes exited 0; physical execution/metadata absence and external persistence were mocked. Docker E2E was not run.
  • This is a code-scope result. CI was not reviewed; the local style verification above was completed independently.

@rishi-rana

Copy link
Copy Markdown
Contributor Author

Thanks, both confirmed and addressed in 553a0f3.

  1. ContextManager.java:307 — the speculative route is now removed only when it wasn't already registered before this call. A table that already had a persisted route is left for dropTables() to clean up itself, so its own isNeedRefresh check sees the route still present and persists the SINGLE config change correctly.
  2. StandardDatabaseProxyConnector.java:296-299 — each table's schema is now resolved from its own SimpleTableSegment.getOwner(), falling back to the statement's default schema only when a table isn't schema-qualified.

Verification: 923 tests pass across the full mode/core and proxy/backend/core modules; spotless:check checkstyle:check -Pcheck clean. Also re-verified checkstyle:check -Pcheck against a worktree merging this branch onto current master, given the last round's surprise.

  1. Still awaiting your sign-off on the support contract.

@rishi-rana

Copy link
Copy Markdown
Contributor Author

Note on the CI failure (Build E2E Image / Prepare E2E Artifacts): it's unrelated to this PR. master itself currently fails to compile — #40102 added a test call using the pre-#39984 registerBlob signature, and the two PRs merged without either rebasing on the other. Filed as #40150, fix open as #40151. CheckStyle, Spotless, and License all passed on this PR independently of that breakage.

@rishi-rana
rishi-rana requested a review from terrymanu October 30, 2026 00:33

@terrymanu terrymanu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Summary

This PR defers PostgreSQL transactional table-DDL metadata refresh until transaction end and reconciles each affected table against storage. The latest guard fixes the previously reported implicit XA result-set closure. Remaining concerns affect the support contract, transaction cleanup, and documentation.

Result

Review Result: Not Mergeable
Feedback Mode: Needs Discussion
Review Status: Not Converged
Confirmed Blocking Issues: 5

These findings are a confirmed subset. Required ledger/session validation could not finish because the public head commit is unavailable locally.

Blocking Issues

  1. [P2] The transactional DDL support contract still needs acceptance

    • Evidence: The current documentation introduces LOCAL/XA table-DDL support and transaction-local visibility restrictions. The latest author reply reframes that contract without a subsequent maintainer decision.
    • Impact: Sharing a refresh mechanism does not settle the newly supported statement, transaction, storage, and visibility boundaries.
    • Discussion Needed: Explicitly accept or adjust those boundaries.
  2. [P2] Removing a logical database can prevent transaction cleanup

    • Evidence: The deferred queue resolves the database again. If another session has removed it, reconciliation dereferences null, including in its error logger.
    • Impact: After deferred DDL and concurrent logical-database removal, COMMIT can throw an NPE, mask its original failure, and skip clearing transaction state and deferred work.
    • Discussion Needed: Transaction cleanup must remain guaranteed when queued database metadata disappears.
  3. [P2] Early connection release discards cleanup errors

  4. [P2] Transaction appendices contradict the new XA support

    • Evidence: Both English and Chinese appendices still prohibit metadata-changing PostgreSQL XA DDL, while the changed limitations permit it.
    • Impact: Users receive conflicting support guidance.
    • Discussion Needed: Publish one consistent XA contract after the support decision.
  5. [P2] Added comments violate the written comment standard

    • Evidence: The new explanatory line comments violate CODE_OF_CONDUCT.md:71, which permits Javadoc, TODO, and FIXME comments.
    • Impact: The additions fail an applicable manual standard despite passing automated style checks.
    • Discussion Needed: The retained implementation must satisfy that existing requirement.

Issues 2–4 already existed at the previously reviewed head and were missed earlier. Issue 5 was introduced by the latest commit.

Coverage

  • Public head: feef5064e46dea279ec343abc9729799515cffe7. Both independent assessments inspected all 31 changed files; snapshot contents matched their public blob hashes.
  • Checkstyle and Spotless passed, exit 0, covering all 27 changed Java files; Checkstyle also covered the E2E properties file. All 164 focused tests passed. The broader dependency build timed out, exit 124; narrowed Proxy tests subsequently passed.
  • Ledger initialization exited 1 because git merge-base exited 128 for the missing head object; session validation remained unavailable. This is a code-scope assessment: CI was not reviewed, and Docker E2E was not run. No source or remote state was changed.

- Skip reconciling a deferred table whose database no longer exists
  instead of passing null into ContextManager#reconcileTable, which
  threw an uncaught NPE (including from its own error logger) and
  skipped the rest of commit's transaction cleanup.
- Propagate exceptions returned by closeConnections(false) instead of
  discarding them, without masking a concurrent commit failure: the
  original commit exception is kept and the close exception attached
  via addSuppressed when both occur.
- Extract the early-release rationale into a Javadoc'd private method
  instead of an inline // comment, which CODE_OF_CONDUCT.md's comment
  standard doesn't permit.
- Document PostgreSQL's XA exception for the four table-DDL statements
  in both transaction appendix docs, which still described the old,
  fully-restricted behavior.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@rishi-rana

Copy link
Copy Markdown
Contributor Author

Thanks, addressed in a19dce6.

1. Support contract still needs acceptance

No code action possible here — same as before, flagging it's still open rather than re-arguing it.

2. Removing a logical database can prevent transaction cleanup

Confirmed and fixed. DeferredMetaDataRefreshContext.reconcile() now skips a deferred table whose database no longer exists instead of passing null into ContextManager#reconcileTable, which threw an uncaught NPE (including from its own error logger) and skipped the rest of commit's cleanup. Added assertReconcileSkipsTableWhoseDatabaseNoLongerExists, verified it fails against the unguarded code.

3. Early connection release discards cleanup errors

Fixed. closeConnections(false)'s returned exceptions are now propagated via the existing throwSQLExceptionIfNecessary helper, after reconciliation runs (connections are still released and reconciled even if a reset failed). This doesn't mask a concurrent commit failure: if localTransactionManager.commit() also threw, that original exception is what's thrown, with the close exception attached via addSuppressed. Added two tests covering both orderings, verified both fail against the discarding version.

4. Transaction appendices contradict the new XA support

Fixed — updated both appendix.en.md and appendix.cn.md to state PostgreSQL's exception for the four table-DDL statements, rather than the old fully-restricted wording.

5. Added comments violate the comment standard

Fixed — extracted the early-release rationale into a Javadoc'd private method (reconcileDeferredMetaDataIfAny) instead of inline // comments.

Verification

207 targeted unit tests pass across mode/core and proxy/backend/core; spotless:check checkstyle:check -Pcheck clean; no line exceeds 200 characters in the diff.

@rishi-rana
rishi-rana requested a review from terrymanu October 31, 2026 03:09

@terrymanu terrymanu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Summary

This PR defers metadata refresh for PostgreSQL transactional table DDL until the transaction ends, then reconciles metadata against the final storage state. This addresses uncommitted changes being invisible to the refresh connection, but two metadata correctness defects, an unsettled support contract, and manual coding-standard violations remain.

Result

Review Result: Not Mergeable
Feedback Mode: Needs Discussion
Review Status: Not Converged
Confirmed Blocking Issues: 5

These findings are a confirmed subset. Ledger and session validation could not complete because the PR head Git object is unavailable locally.

Blocking Issues

  1. [P2] The new transactional DDL support contract still requires maintainer acceptance

    • Evidence: The current limitations publish statement, LOCAL/XA, storage, and transaction-local visibility commitments. The latest author reply explicitly states that acceptance remains pending. In addition, the admission logic checks only physical storage capabilities, allowing openGauss-protocol sessions over PostgreSQL storage despite the documented openGauss restriction.
    • Impact: Reusing the refresh mechanism does not establish the complete support contract users can rely on.
    • Discussion Needed: Explicitly accept or adjust the statement, transaction-type, protocol, storage, and transaction-local visibility boundaries.
  2. [P2] Renaming a table to "dual" omits the destination metadata refresh

    • Evidence: Deferred refresh collects targets from TablesContext, which filters every case-insensitive occurrence of DUAL, including real quoted table names. A current-source probe confirmed this filtering.
    • Impact: With one PostgreSQL storage unit, BEGIN; ALTER TABLE foo RENAME TO "dual"; COMMIT; queues only the old table. Commit removes foo from metadata without registering the renamed table.
    • Discussion Needed: The accepted rename support must preserve every real DDL target.
  3. [P2] Deferred CREATE loses the information needed to recover long logical index names

    • Evidence: Reconciliation passes only existing schemas. The established CREATE refresh implementation also supplies index-name candidates from the statement. A source probe confirmed that names shortened by the identifier-length rewrite cannot be recovered without those candidates.
    • Impact: Creating a sharded table with a long named index inside a transaction persists the shortened physical index name in metadata instead of the original logical name.
    • Discussion Needed: Deferred refresh must preserve the existing CREATE path’s logical index identity contract.

    Issues 2 and 3 already existed at the previously reviewed head, feef5064…. They were missed in the earlier review and were not introduced by the latest fixes.

  4. [P2] Four modified expressions violate the line-wrapping rule

    • Evidence: The complete expressions at MariaDB:38, openGauss:91, Oracle:85, and PostgreSQL:83 measure 190, 185, 197, and 186 characters respectively, including indentation.
    • Impact: They violate the applicable rule requiring modified expressions of at most 200 characters to remain on one line. The automated checks do not enforce this rule.
    • Discussion Needed: The retained implementation must satisfy the existing line-wrapping standard.
  5. [P2] New exception-propagation tests do not use reference-identity assertions

    • Evidence: Test lines 358 and 375 compare the original exception objects using is(...). The coding standard requires sameInstance(...) for reference identity.
    • Impact: Runtime behavior is currently equivalent, but the tests do not express the “preserve the original exception object” contract using the required assertion.
    • Discussion Needed: The retained tests must satisfy the existing reference-identity assertion standard.

Coverage

  • Public PR head: a19dce6084a9b2e85656b6604388d4a305fc98bf. Two independent manual assessments covered all 33 changed files. Snapshot hashes matched, and the head was rechecked before completion.
  • Checkstyle and Spotless passed for all 27 Java files; Checkstyle also passed for the properties file. The source dependency build and all 167 selected unit tests passed, with exit code 0.
  • Ledger initialization exited 1 because the missing head object caused git merge-base to exit 128; session validation remained incomplete. This is a code-scope assessment: CI was not reviewed, and Docker E2E was not run.

…covery

- Also require the session's own protocol to support transactional DDL,
  not just each routed storage unit. A PostgreSQL-protocol check alone
  let an openGauss-protocol session routed to PostgreSQL storage defer
  refresh, even though openGauss never sets this capability.
- Read the statement's own table attribute instead of TablesContext when
  collecting deferred tables. TablesContext drops every table named DUAL
  case-insensitively to exclude the SQL pseudo-table convention, which
  also silently dropped a real DDL target legitimately named "dual".
- Carry a CREATE TABLE statement's declared index-name candidates through
  to commit-time reconciliation, so a storage-imposed identifier-length
  limit shortening a long index name can still be recovered the same way
  the synchronous CREATE path already recovers it.
- Merge four DialectTransactionOption constructions onto one line each;
  all fit within 200 characters.
- Use sameInstance() instead of is() for reference-identity assertions.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@rishi-rana

Copy link
Copy Markdown
Contributor Author

Thanks, addressed in 1f17062.

1. Support contract still needs acceptance

The sub-finding (openGauss-protocol over PostgreSQL storage) is fixed, see point 2 below. The contract itself still needs your sign-off; no further code action possible on my side.

2. Renaming a table to "dual" omits the destination metadata refresh

Confirmed and fixed. deferMetaDataRefresh now reads the statement's own TableSQLStatementAttribute directly instead of TablesContext#getSimpleTables(), which drops every table named DUAL case-insensitively to exclude the SQL pseudo-table convention — including a real DDL target legitimately named dual. Added assertExecuteDefersMetaDataRefreshForRenameDestinationNamedDual, verified it fails against the pre-fix code.

While fixing this I also closed the gap it pointed at in point 1: isDeferrableTableDDL now also checks the session's own protocol type's isSupportTransactionalDDL(), not just each routed storage unit's, so an openGauss-protocol session routed to PostgreSQL storage correctly falls through to rejection instead of being admitted. Added assertExecuteDoesNotDeferMetaDataRefreshWhenProtocolDoesNotSupportTransactionalDDL, verified it fails against the pre-fix code.

3. Deferred CREATE loses information needed to recover long logical index names

Confirmed and fixed. Extracted CreateTablePushDownMetaDataRefresher's revision-candidate-schema logic into reusable static methods. deferMetaDataRefresh now captures the created table's index-name candidates at admission time, carries them through DeferredMetaDataRefreshContext, and ContextManager#reconcileTable builds the same revision-candidate schema the synchronous CREATE path already builds, instead of always passing database.getAllSchemas(). Added a regression test at each layer (StandardDatabaseProxyConnectorTest and ContextManagerTest), verified both fail against the pre-fix code.

4. Four modified expressions violate the line-wrapping rule

Fixed — all four DialectTransactionOption constructions merged onto one line; reconstructed lengths (190/185/197/186 characters) match what you reported, confirming the fix targets the right lines.

5. New exception-propagation tests should use reference-identity assertions

Fixed — both tests now use sameInstance(...) instead of is(...).

Verification

213 targeted unit tests pass across mode/core, proxy/backend/core, and the four DialectTransactionOption dialect modules; spotless:check checkstyle:check -Pcheck clean; no line exceeds 200 characters in the diff.

…idates

- Only defer the table a CREATE/ALTER TABLE statement actually targets,
  not the foreign-key-referenced tables TableSQLStatementAttribute also
  exposes for binding purposes. A referenced table was never routed by
  the statement, so it could be reconciled against an arbitrary fallback
  datasource and, on a miss, incorrectly dropped from meta data.
- Replace rather than no-op a deferred table's existing entry when it is
  added again in the same transaction, so a later statement's revision
  candidate indexes are not silently discarded in favor of an earlier,
  stale set for the same table name.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@rishi-rana
rishi-rana requested a review from terrymanu November 10, 2026 23:32

@terrymanu terrymanu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Correction

Previous Finding or Conclusion: The previous runtime finding that deferred CREATE loses long logical index names.
Current Status: Withdrawn
Reason: The real PostgreSQL CREATE path populates constraintName, but does not produce the indexName read by the index-candidate extraction logic. A current-source probe also confirmed an empty candidate collection. This parser is unchanged from the previously reviewed head, so the earlier conclusion lacked evidence of a reachable production path.

Summary

This PR defers metadata refresh for PostgreSQL transactional table DDL until commit, then reconciles metadata against the final storage state. This addresses the refresh connection’s inability to see uncommitted DDL; the complete support contract and the following design, documentation, and coding-standard issues still need resolution.

Result

Review Result: Not Mergeable
Feedback Mode: Needs Discussion
Review Status: Not Converged
Confirmed Blocking Issues: 4

The findings below are a confirmed subset. Code inspection and local verification finished, but the missing local Git object for the PR head prevented completion of formal ledger and session validation.

Blocking Issues

  1. [P2] The new transactional DDL support contract still requires maintainer acceptance

    • Evidence: The current limitations promise LOCAL/XA table-DDL support and prohibit referencing a table created earlier in the same transaction. The author’s latest reply explicitly states that acceptance remains pending.
    • Impact: The original issue supports fixing metadata refresh after committing ALTER TABLE, but does not settle every newly supported statement, transaction type, or visibility limitation.
    • Discussion Needed: Explicitly accept or adjust the statement scope, LOCAL/XA/BASE boundary, protocol and storage requirements, and visibility of newly created tables within the transaction.
  2. [P2] The new index payload has no real PostgreSQL CREATE producer

    • Evidence: The PostgreSQL visitor populates constraintName, while the index extraction method reads only indexName. The binder does not populate that field.
    • Impact: The new public methods, overload, queue field, and cross-module parameters carry only empty collections under the only currently enabled protocol. The associated getCreatedTable helper also introduces an undocumented null-return sentinel.
    • Discussion Needed: Establish the actual production requirement for this shared state and API surface. Tests that manually inject nonempty collections do not establish necessity. Existing synchronous-refresh uses in other dialects should remain supported.
  3. [P2] The documentation promises a standalone RENAME TABLE statement PostgreSQL cannot execute

    • Evidence: All four transaction documents add this claim, including appendix.en.md:10. PostgreSQL’s documented syntax is ALTER TABLE … RENAME TO; the current-source parser probe rejects standalone RENAME TABLE.
    • Impact: A user following the supported-statement list encounters a parsing failure before deferred refresh is reached. This wording already existed at the previously reviewed head and was missed in that review.
    • Discussion Needed: The support contract must distinguish internal statement categories from executable PostgreSQL syntax.
  4. [P2] The new private helpers are not declared in their caller’s call order

    • Evidence: deferMetaDataRefresh calls getRenameSchemaSources first, but the subsequent declarations begin with getDeferrableTables. This violates the explicit requirement in CODE_OF_CONDUCT.md:48.
    • Impact: The added method layout does not satisfy the repository’s written standard. Passing automated style checks does not establish compliance with this rule.
    • Discussion Needed: The final retained helpers must follow the required declaration order.

Coverage

  • Public PR head: 3ce07a804aab0ea0fc33bf6872f501b4a402d454. Two independent code inspections covered all 34 files. Every snapshot blob matched GitHub’s file inventory, and the head remained unchanged before delivery.
  • All 28 Java files passed Checkstyle and Spotless; the changed properties file passed a separate Checkstyle check. The current-source build and all 173 tests across nine selected classes passed, with exit code 0. The parser probe also passed.
  • Ledger initialization exited 1 because the underlying git merge-base command exited 128; session validation remains incomplete. This is a code-scope assessment: CI was not reviewed, and Docker E2E was not run.

rishi-rana and others added 3 commits November 17, 2026 18:19
… order

PostgreSQL has no standalone RENAME TABLE statement; renaming a table goes
through ALTER TABLE ... RENAME TO. Reworded limitations.en.md/.cn.md and
appendix.en.md/.cn.md to describe that actual syntax instead of a statement
category PostgreSQL's parser rejects.

Reordered StandardDatabaseProxyConnector's six deferMetaDataRefresh helpers
(getRenameSchemaSources, getCreatedTable, getDeferrableTables,
getBoundSchemaName, findLogicDataSourceName, getRevisionCandidateIndexes) to
match their actual call order, per CODE_OF_CONDUCT.md's private-helper
ordering rule. Pure reordering, no logic change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…fresh-in-transaction

# Conflicts:
#	RELEASE-NOTES.md
CreateTablePushDownMetaDataRefresher.createRevisionCandidateIndexes reads
ConstraintDefinitionSegment.getIndexName(), which PostgreSQL's CREATE TABLE
grammar never populates: the only rule that sets it (tableConstraintUsingIndex)
is reachable only from ALTER TABLE ADD CONSTRAINT ... USING INDEX, never from
createTableConstraint. Since deferred refresh currently only applies to
PostgreSQL, the revisionCandidateIndexes collection this PR threaded through
ContextManager.reconcileTable and DeferredMetaDataRefreshContext was always
empty. Removed that plumbing; reconcileTable now calls database.getAllSchemas()
directly, matching the removed call's own empty-collection behavior. The
underlying mechanism is untouched and still serves MySQL's synchronous refresh
path, where it has a real producer.

Assisted with AI Claude (Claude Code). Affected files: ContextManager.java,
StandardDatabaseProxyConnector.java, DeferredMetaDataRefreshContext.java and
their tests.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@rishi-rana

Copy link
Copy Markdown
Contributor Author

Addressed the remaining items:

Index-payload plumbing (item 2): removed. Traced PostgreSQL's actual grammar — tableConstraintUsingIndex (the only rule populating indexName) is only reachable from ALTER TABLE ADD CONSTRAINT ... USING INDEX, never from CREATE TABLE's own createTableConstraint rule — so the deferred-path's revisionCandidateIndexes payload was always empty under the only dialect this PR enables deferred refresh for. Removed the reconcileTable overload, DeferredMetaDataRefreshContext's extra field, and StandardDatabaseProxyConnector.getRevisionCandidateIndexes()/the getCreatedTable() branch; reconcileTable now calls database.getAllSchemas() directly, which is exactly what the removed call did for an empty collection. The underlying mechanism itself (CreateTablePushDownMetaDataRefresher.createRevisionCandidateSchemas/createRevisionCandidateIndexes) is untouched and still serves MySQL's synchronous refresh path, where it has a real producer.

Doc wording (item 3): fixed — limitations.en.md/.cn.md and appendix.en.md/.cn.md now say RENAME TO instead of the nonexistent RENAME TABLE for PostgreSQL.

Helper declaration order (item 4): fixed — StandardDatabaseProxyConnector's private helpers now follow their call order inside deferMetaDataRefresh, per CODE_OF_CONDUCT.md.

Item 1 (the overall transactional-DDL support contract) is still open for your/maintainer sign-off.

Assisted with AI Claude (Claude Code). Affected files: ContextManager.java, StandardDatabaseProxyConnector.java, DeferredMetaDataRefreshContext.java and their tests; limitations.en.md, limitations.cn.md, appendix.en.md, appendix.cn.md.

🤖 Generated with Claude Code

@rishi-rana
rishi-rana requested a review from terrymanu November 24, 2026 01:33

@terrymanu terrymanu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Summary

This PR addresses metadata refresh being unable to see uncommitted PostgreSQL DDL through a separate connection. It records affected tables, reconciles metadata against the actual storage state after a commit attempt, and restricts eligibility by protocol, storage capability, and transaction type. The mechanism addresses the identified root cause, but the support contract and the following design and standards issues remain unresolved.

Result

Review Result: Not Mergeable
Feedback Mode: Needs Discussion
Review Status: Not Converged
Confirmed Blocking Issues: 4

The findings below are a confirmed subset. Two independent code inspections completed, but the missing local Git object for the PR head prevented completion of formal ledger and session validation.

Blocking Issues

  1. [P2] The transactional DDL support contract still requires maintainer acceptance

    • Evidence: The current limitations promise table-DDL support for LOCAL/XA transactions while preventing subsequent statements from referencing tables created within the same transaction. The author’s latest reply explicitly states that the overall contract still awaits maintainer sign-off.
    • Impact: The supported statements, transaction types, protocol/storage combinations, and visibility boundaries users can rely on remain unsettled.
    • Discussion Needed: Explicitly accept or adjust these support boundaries.
  2. [P2] Public helper methods remain without cross-class consumers after removal of the index payload

    • Evidence: The two CREATE helper methods were changed from private methods to public static methods. Their only current caller is the same class’s refresh method; deferred refresh no longer calls them.
    • Impact: The newly exposed public boundary has no current production consumer requiring it, contrary to the minimum-access requirement. The existing synchronous index-recovery behavior itself remains necessary.
    • Discussion Needed: Establish whether these two internal computations need to become public contracts.
  3. [P2] Two added or modified Java constructs violate the line-wrapping rules

    • Evidence: The CREATE helper declaration occupies three lines, although its first two lines total only 189 characters and the declaration fits in two lines. The complete test initialization statement is 184 characters long.
    • Impact: These constructs violate the current written wrapping rules, which Checkstyle and Spotless do not fully enforce. Both issues existed in the previously reviewed version and were missed in that review.
    • Discussion Needed: The retained code must satisfy the current minimum-line-break rules.
  4. [P2] Added ordinary Javadocs contain implementation explanations prohibited by the current rules

    • Evidence: The private helper’s Javadoc expands into implementation rationale and steps, contrary to the current Javadoc rules. Similar added paragraphs appear in ContextManager, the CREATE refresher, DeferredMetaDataRefreshContext, ProxyBackendTransactionManager, and both new E2E classes.
    • Impact: These ordinary internal declarations do not meet the current requirement for concise responsibility descriptions.
    • Discussion Needed: The final documentation should preserve necessary contracts while complying with the current Javadoc wording rules.

Coverage

  • Public PR head: 01ef8ba932050efcc0e56fafae5dd4b19c516dfa. Two independent source inspections covered all 34 files. The head and discussion were rechecked and remained unchanged before delivery.
  • Checkstyle covered 28 Java files and the properties file; Spotless covered all 28 Java files. Both exited 0. All 176 tests across 10 focused test classes passed, with zero failures or errors.
  • Ledger initialization exited 1 because the underlying git merge-base exited 128 for the missing head object; session validation exited 1. This is a code-scope assessment: CI was not reviewed, and Docker E2E was not run.

…ort wrapped line

Revert CreateTablePushDownMetaDataRefresher to upstream now that nothing
calls its revision-candidate helpers, reduce the Javadocs added by this
PR to concise responsibility descriptions, and join a test statement
that fits within 200 characters.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@rishi-rana

Copy link
Copy Markdown
Contributor Author

Thanks, addressed in 2f3ca9b.

[P2] Public helper methods without cross-class consumers

CreateTablePushDownMetaDataRefresher is restored to its upstream content, so createRevisionCandidateSchemas and createRevisionCandidateIndexes are private again and the PR no longer touches that file.

[P2] Line-wrapping violations

The CREATE helper declaration is gone with the revert. The test initialization in StandardDatabaseProxyConnectorTest is now a single 184-character line. I also checked the other wrapped statements this PR adds. The three remaining builder chains are 312 to 353 characters when joined, so their wrapping stays.

[P2] Javadocs with implementation explanations

The Javadocs this PR adds in StandardDatabaseProxyConnector, ContextManager, DeferredMetaDataRefreshContext, ProxyBackendTransactionManager and both E2E test cases are now one-phrase responsibility descriptions with @param and @return only. The CREATE refresher Javadocs left with the revert.

[P2] Transactional DDL support contract

No code change. This still needs maintainer acceptance of the support boundaries in limitations.en.md: LOCAL/XA table DDL, and no references to tables created in the same transaction.

🤖 Generated with Claude Code

@rishi-rana
rishi-rana requested a review from terrymanu November 28, 2026 22:38

@terrymanu terrymanu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Summary

This PR addresses metadata refresh being unable to see uncommitted PostgreSQL DDL through a separate connection. It records affected tables and reconciles metadata against the final storage state during commit. The mechanism addresses the reported problem, but the support contract, E2E polling behavior, and one newly introduced fallback still need resolution.

Result

Review Result: Not Mergeable
Feedback Mode: Needs Discussion
Review Status: Not Converged
Confirmed Blocking Issues: 3

The following findings are a confirmed subset. Formal ledger and session validation could not complete.

Blocking Issues

  1. [P2] The transactional-DDL support boundaries still require maintainer acceptance

    • Evidence: The current limitations promise table-DDL support for LOCAL/XA transactions while prohibiting references to tables created earlier in the same transaction. The latest author reply explicitly states that these boundaries still await acceptance.
    • Impact: The supported statements, transaction types, protocol/storage combinations, and transaction-local visibility contract remain unsettled.
    • Discussion Needed: Explicitly accept or adjust these support boundaries.
  2. [P2] SQL exceptions during normal metadata convergence prematurely terminate the new E2E polling

    • Evidence: The PostgreSQL test:117 and MySQL test:67 directly poll queries that can throw SQLException. Source tracing and probes against the current dependencies confirm that Awaitility propagates the first exception.
    • Impact: After DROP COLUMN, before Cluster metadata catches up, the logical column count can differ from the physical result set. The resulting query error can fail a correct implementation before the 30-second wait expires. This is a conditional failure established from source and probes; Docker reproduction was not performed.
    • Discussion Needed: The acceptance checks must tolerate normal asynchronous convergence while preserving timeout failures. A query exception must not count as evidence that the column has been removed.
  3. [P2] The new empty-collection fallback has no supported missing-attribute condition

    • Evidence: The remaining paths at StandardDatabaseProxyConnector.java:388 accept only DROP/RENAME statements. Both final statement types guarantee TableSQLStatementAttribute through their constructors.
    • Impact: No production condition justifies the empty-collection fallback, contrary to the applicable defensive-code rules. This is a standards violation, not a claim of an observed runtime failure.
    • Discussion Needed: The final implementation should follow the existing required-attribute contract.

Issues 2 and 3 already existed at the previously reviewed head, 01ef8ba9…, and were missed in that review.

Coverage

  • Public PR head: 2f3ca9b666e6e008588163af03b7a35a1fab4c56. Two independent source assessments covered all 33 files. The head was rechecked before delivery and remained unchanged.
  • Checkstyle and Spotless passed for all 27 Java files; Checkstyle also passed for the changed properties file. All 174 focused unit tests passed against current sources, with exit code 0.
  • E2E test-compile exited 1 before compilation because snapshot dependencies were missing; Docker E2E was not run. The missing local head Git object caused ledger initialization to exit 1, with the underlying git merge-base exiting 128; session validation also exited 1. This is a code-scope assessment; CI was not reviewed.

…metadata

Read TableSQLStatementAttribute through getAttribute for drop and rename
statements, which always carry it, and make the DDL metadata refresh E2E
cases ignore transient query errors while waiting for metadata to converge.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@rishi-rana

Copy link
Copy Markdown
Contributor Author

Thanks, addressed in 8ef0445.

[P2] SQL exceptions during metadata convergence end the E2E polling early

awaitColumnPresence in PostgreSQLDDLMetaDataRefreshTestCase and MySQLDDLMetaDataRefreshTestCase now polls with ignoreExceptions(). A query that fails while the logical and physical columns disagree counts as "not yet" and never as evidence that the column was removed. A condition that never holds still fails at the 30-second timeout.

[P2] Empty-collection fallback without a supported missing-attribute condition

getDeferrableTables now reads TableSQLStatementAttribute through getAttribute(...), the required-attribute accessor. The fallback is removed. The only statements that reach this path are DROP and RENAME, and both constructors always create the attribute.

[P2] Transactional DDL support contract

No code change. This still needs maintainer acceptance of the support boundaries in limitations.en.md: LOCAL/XA table DDL, and no references to tables created in the same transaction.

🤖 Generated with Claude Code

@rishi-rana
rishi-rana requested a review from terrymanu December 1, 2026 01:59

@terrymanu terrymanu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Summary

This PR records affected tables and reconciles metadata against the final storage state during commit, addressing PostgreSQL transactional DDL being invisible to a separate metadata-refresh connection before commit. The latest commit fixes the exception-polling and empty-collection fallback findings. The support contract and the following design and standards issues remain unresolved.

Result

Review Result: Not Mergeable
Feedback Mode: Needs Discussion
Review Status: Not Converged
Confirmed Blocking Issues: 3

The findings below are a confirmed subset. Ledger and session validation remain incomplete, so formal review completion cannot be claimed.

Blocking Issues

  1. [P2] The transactional-DDL support boundaries still require maintainer acceptance

    • Evidence: The current documentation promises LOCAL/XA table-DDL support while preventing subsequent statements from referencing tables created within the same transaction. The author’s latest reply explicitly states that these boundaries still await acceptance.
    • Impact: Previously rejected operations become a new user-facing contract. Sharing a refresh mechanism does not establish project acceptance.
    • Discussion Needed: Accept or adjust the supported statements, transaction types, storage requirements, and transaction-local visibility limitations.
  2. [P2] The standalone RenameTableStatement deferral path has no enabled production dialect

  3. [P2] One fluent expression violates the explicit line-wrapping rules

Issues 2 and 3 were already present at the previously reviewed head, 2f3ca9b6…, and were missed in that review.

Coverage

  • Public head: 8ef044599f445d30ba4566d3436dd8be466e9bdd. Two independent source assessments covered all 33 files, followed by coordinator verification of the findings above.
  • Checkstyle and Spotless passed for all 27 Java files with exit code 0. The separate Checkstyle run for the changed properties file also exited 0. File-selection coverage was verified.
  • Ledger initialization exited 1 because the public-head object is unavailable locally; the underlying git merge-base exited 128. Session validation exited 1. Unit and E2E tests were not run in this round. This is a code-scope assessment; CI was not reviewed.

No dialect that supports transactional DDL produces a standalone
RenameTableStatement, so drop its deferral branch and dedicated test, and
keep stream() on the first line of the routed-table check in ContextManager.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@rishi-rana

Copy link
Copy Markdown
Contributor Author

Thanks, addressed in 330c260.

[P2] Standalone RenameTableStatement deferral path without an enabled production dialect

I removed the RenameTableStatement branch from isDeferrableTableDDLStatement and getRenameSchemaSources in StandardDatabaseProxyConnector, together with its dedicated test. The standalone statement is produced only by the MySQL and Doris parsers, and neither supports transactional DDL. ALTER TABLE ... RENAME TO still defers through AlterTableStatement, which is what the PostgreSQL parser produces.

[P2] Line-wrapping violation in ContextManager

.stream() now stays on the first line of the routed-table check, which is 124 characters, and only .anyMatch(...) is on the continuation line.

[P2] Transactional DDL support contract

No code change. This still needs maintainer acceptance of the support boundaries in limitations.en.md: LOCAL/XA table DDL, and no references to tables created in the same transaction.

🤖 Generated with Claude Code

@terrymanu terrymanu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Correction

Previous Finding or Conclusion: The transactional-DDL support boundary remains unresolved.
Current Status: Retained.
Reason: The earlier formal review missed that the visibility limitation also affects new columns on existing tables. This was already present at the same reviewed head.

Summary

This PR addresses metadata-refresh connections being unable to see uncommitted PostgreSQL DDL. Because the reported issue requires bypassing an existing restriction, the patch also introduces new supported transaction-DDL paths. Reconciling final storage state after commit is reasonable, but it does not provide transaction-local visibility of changed structures.

Result

Review Result: Not Mergeable
Feedback Mode: Needs Discussion
Review Status: Not Converged
Confirmed Blocking Issues: 2

The following findings are a confirmed subset. Canonical ledger and session validation could not complete because the PR head Git object is unavailable locally.

Blocking Issues

  1. [P2] Define transaction-local visibility before enabling table-DDL support

    • Evidence: The refresh branch defers metadata changes until commit. Subsequent statements still bind against global metadata, where unknown columns are rejected.
    • Impact: For an existing t(id INT), BEGIN; ALTER TABLE t ADD COLUMN c INT; INSERT INTO t(id,c) VALUES (1,1); COMMIT; reaches old-schema column validation before commit. This is established by source tracing; no live reproduction was run. The documented exception explicitly mentions newly created tables, so it understates the limitation.
    • Discussion Needed: Agree whether support limited to post-commit metadata convergence is acceptable, including restrictions on later statements using changed structures. The author still leaves this acceptance pending. If transaction-local visibility is required, the present mechanism is insufficient.
  2. [P2] Newly introduced normal-throughput helpers lack required annotations

    • Evidence: New connector helpers run for ordinary SQL. The new commit helper and queue isEmpty/clear methods run with normal transaction throughput. None has an applicable HighFrequencyInvocation annotation, as required by CODE_OF_CONDUCT.md:56–61.
    • Impact: This violates the written annotation requirement. No measured performance regression is claimed.
    • Discussion Needed: Any retained implementation must satisfy the existing annotation contract.

Coverage

  • Public head: 330c2608dcab7867f2e9f36bcdce3c920d2f91ea. All 33 changed files were re-inspected; the head and public discussion remained unchanged.
  • Prior local Checkstyle and Spotless checks passed across all 12 affected modules, exit 0. Results were reused after verifying unchanged candidate, configuration, tools and coverage of all 27 Java files; Checkstyle also covered the changed properties file.
  • Canonical inventory and ledger initialization exited 1, with underlying git merge-base exit 128 for the missing head object. Session validation remains incomplete. This is a code-scope assessment: unit/E2E tests were not run, and CI was not reviewed.

…ity limit

Mark the deferrable-DDL check, the commit-time reconcile guard and the
deferred queue isEmpty/clear as high-frequency, and state in the
limitations pages that any structure changed by DDL earlier in the same
transaction, including new columns of existing tables, is not visible to
later statements.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@rishi-rana

Copy link
Copy Markdown
Contributor Author

Thanks, addressed in e0b1b18.

[P2] Define transaction-local visibility before enabling table-DDL support

This PR supports metadata convergence at commit only. It does not provide transaction-local visibility, and I am proposing that as the supported scope. Statements later in the same transaction bind against the metadata as it was before the transaction's DDL, whether the DDL created a table, added a column to an existing table, or renamed a table.

The limitations pages (English and Chinese) now state this in full. They previously mentioned only tables created in the same transaction. They now cover any structure changed by DDL earlier in the transaction, and give BEGIN; ALTER TABLE t ADD COLUMN c INT; INSERT INTO t (id, c) VALUES (1, 1); as a second example alongside the CREATE TABLE one.

If you would prefer transaction-local visibility, I can open that as a separate design discussion. It needs a different mechanism from this deferred reconcile.

[P2] Newly introduced normal-throughput helpers lack required annotations

@HighFrequencyInvocation is now on StandardDatabaseProxyConnector.isDeferrableTableDDL, ProxyBackendTransactionManager.reconcileDeferredMetaDataIfAny, and DeferredMetaDataRefreshContext.isEmpty and clear. The annotated bodies use no streams and no + concatenation. I did not annotate add, reconcile, deferMetaDataRefresh or isInDeferrableTransaction, because they run only for deferred table DDL.

🤖 Generated with Claude Code

This branch has not been deployed

No deployments
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.

Metadata Not Refreshed After Executing DDL Within PostgreSQL Transaction

3 participants