Repository navigation
Closed
Labels
Description
Conclusion
Consolidate all scattered DDL execution and column validation into one place: DDL stays defined once in the dialect layer; execution and validation happen together inside AbstractJdbcDialectBuilder.build(). The framework never alters existing tables — missing columns fail the build with the reference CREATE TABLE DDL — and store constructors drop all schema responsibilities.
Current state
DDL definitions are centralized in the dialect layer (createTableDdls()), but execution and validation are scattered across five places:
AbstractJdbcDialectBuilder.build()(autoCreateTable)JdbcAgentStateStoreconstructor (createIfNotExist, plus a table-existence probe)JdbcStore.Builder(initializeSchema)JdbcRemoteSnapshotClient(same flag;JdbcSnapshotSpecforwards it)AbstractJdbcDialect.ensureLockTable()(lazy lock-table creation)
Problems
- Duplicate execution:
JdbcDistributedStore.create()creates all three tables via the builder, then each lazily built component re-runs its ownCREATE TABLE IF NOT EXISTSon first access. Three flag names for one concept, with inconsistent semantics — the builder'sfalsejust skips creation, while the store'sfalseprobes and throws. - No schema-mismatch detection: migrating from the deprecated mysql/postgresql extensions lands on the same table name,
CREATE TABLE IF NOT EXISTSis a no-op on the legacy table, and it is silently adopted. Unversioned reads work fine; the first write fails withUnknown column 'version'— discovery is deferred to runtime. - Wrong layer for validation, wrong source for expected columns: column validation needs the dialect (expected schema) and a connection (which the builder already holds at assembly time) — it is assembly-time work, not per-store constructor logic; as long as it lives in one store, the store/snapshots tables get no equivalent guard. Hand-written column lists (requiredColumns) are a second copy of the DDL and will drift.
Proposal
- Derive expected columns by parsing
createTableDdls(): recognizeCREATE TABLEstatements only, take the leading identifier of each definition, skip constraint entries (PRIMARY/INDEX/...). No hand-maintained lists. - Handle both modes in
build(): withautoCreateTable=true, execute all DDL first, then validate all three tables; withfalse, validate without executing any DDL. Validation usesSELECT * FROM t WHERE 1=0+ResultSetMetaData, case-insensitive comparison; report all missing columns at once and log the reference CREATE TABLE DDL. The framework never executes schema changes against existing tables. - Remove schema logic from store constructors; mark the boolean switches
@Deprecated(delegating to the same validation during the transition) and drop them next major version. - Leave
ensureLockTablelazy as-is — MySQL/Postgres use native advisory locks and never touch the lock table. - Also fix
SchedulerConfig/DataPlaneConfig, whereJdbcStore.builder(ds).initializeSchema(true)is called without a dialect (build()throwsIllegalStateExceptionwhen dialect is null).
Activity
oss-maintainer commentedon Sep 26, 2026
Issue Evaluation
Category:
enhancement(area/extensions) | Status: Evaluated — mostly confirmed, two claims need correction | Severity: medium (migration-time failure surfaced only at runtime) | Feasibility: highVerified claim-by-claim against
main@6a056809a(engine-assisted read ofagentscope-extensions/agentscope-extensions-jdbc):autoCreateTable—dialect/AbstractJdbcDialectBuilder.java:63,93-115,148-161; store ctorcreateIfNotExist+ existence probe —state/JdbcAgentStateStore.java:65-117; KV builderinitializeSchema—store/JdbcStore.java:59-81,283-319; snapshot client —snapshot/JdbcRemoteSnapshotClient.java:45-79(flag forwarded bysnapshot/JdbcSnapshotSpec.java:30-50); lazy lock table —dialect/AbstractJdbcDialect.java:252-266,296-311AbstractJdbcDialect.createTableDdls()aggregates store + session + snapshot DDL —dialect/AbstractJdbcDialect.java:116-129, viadialect/table/StoreDialect.java:43-56,SessionStateDialect.java:41-57,SnapshotDialect.java:34-54JdbcDistributedStorepathCREATE TABLE IF NOT EXISTSfalseflagautoCreateTable(false)silently skips (AbstractJdbcDialectBuilder.java:148-161) whileJdbcAgentStateStore(..., false)probes and throws (JdbcAgentStateStore.java:80-117); butJdbcStore.Builder.initializeSchema(false)also just silently skips (JdbcStore.java:59-81), so the split is 2-vs-2 rather than one unified conventionrs.next()on a catalog query,JdbcAgentStateStore.java:102-117); store/snapshotfalsepaths do not probe at all (JdbcStore.java:73-81,JdbcRemoteSnapshotClient.java:62-79)CREATE TABLE IF NOT EXISTSbeing a no-op is right, but the legacy-gap failure can also hit the first read: the store select already projectsversion(dialect/table/StoreDialect.java:90-97, write path:62-87,vendor/H2Dialect.java:62-76). The "deferred discovery" argument stands either wayrequiredColumnslists duplicate the DDLrequiredColumns-style model exists in the module today; the only schema shape source is the per-vendor DDL lists (e.g.vendor/H2Dialect.java:40-59,83-103,134-143). If such a list exists it is being introduced by in-flight work, not by currentmainSchedulerConfig/DataPlaneConfigcallJdbcStore.builder(ds).initializeSchema(true)with no dialectservice-scheduler/.../SchedulerConfig.java:35,113-114,service-dataplane/.../DataPlaneConfig.java:39,119-123) but they import the deprecated MySQLJdbcStore, which auto-detects a dialect (agentscope-extensions-mysql/.../store/JdbcStore.java:103-116). The dialect-lessIllegalStateExceptiononly exists on the new module (agentscope-extensions-jdbc/.../store/JdbcStore.java:310-316), so those two call sites are not currently brokenRelated work to align with (do not duplicate): PR #3244 (
fix(jdbc): fail fast with actionable migration DDL when adopting the deprecated stores' legacy table, OPEN, +226/-2) implements the narrow version of problem 2 for the state table only — touched files arestate/JdbcAgentStateStore.java,dialect/vendor/H2Dialect.javaandstate/JdbcAgentStateStoreH2Test.java. The table names it guards are the same ones this issue wants to cover centrally, so the consolidation should absorb that mechanism rather than sit beside it.Assessment. The core of the proposal — keep DDL declared once in the dialect layer, move both execution and validation into
AbstractJdbcDialectBuilder.build(), and derive expected columns from the parsedcreateTableDdls()instead of a second hand-maintained list — is coherent and localized: 6 classes plus the threedialect/table/*contracts, no cross-module cascade into core/harness/distribution. Detect-only (never auto-ALTER) is the right boundary for a framework, and theSELECT * FROM t WHERE 1=0+ResultSetMetaDataapproach is portable across the four supported dialects.Two things worth deciding before implementation:
@Deprecateddelegation for one minor version, which means both the old and the new path must stay green in tests; the deprecation target (next major) should be named in the Javadoc so it is tracked.DATABASE_TO_UPPERdepends on mode) — recommend comparing on the JDBC metadataResultSetMetaData.getColumnNameset and documenting the fold, otherwise the guard will produce false mismatches on case-sensitive vendors.Suggested test surface, all H2/embedded-datasource, no external services: absent table +
autoCreateTable=true(creates, then validates), absent table +false(single clear failure), legacy table missingversion(validation reports the column and the reference DDL, no DDL executed), idempotent secondbuild(), and one case-folding matrix test per vendor dialect.No automated PR is generated from this evaluation: the issue is a design consolidation across a module owned by an in-flight PR, and PR-shape decisions here need a maintainer call on points 1-2 above.
Automated evaluation by github-manager-bot
refactor(extensions): Consolidate JDBC table creation and column vali…
xzxiaoshan commentedon Sep 28, 2026
complated as #3309