Repository navigation
Description
Describe the bug
agentscope-extensions-jdbc (landed in #2759, tracking #2503) reimplements the session-state store as JdbcAgentStateStore. Its schema bootstrap only ever runs CREATE TABLE IF NOT EXISTS — there is no equivalent of the ensureVersionColumn() migration that both of its predecessors have:
// JdbcAgentStateStore L76-85
public JdbcAgentStateStore(
DataSource dataSource, SessionStateDialect dialect, boolean createIfNotExist) {
this.dataSource = requireNonNull(dataSource, "dataSource");
this.dialect = requireNonNull(dialect, "dialect");
if (createIfNotExist) {
createTableIfNotExist();
} else {
verifyTableExists();
}
}grep -rn "ALTER TABLE" agentscope-extensions/agentscope-extensions-jdbc/src/main returns nothing.
For comparison, the migration does exist in:
agentscope-extensions-mysql/.../state/MysqlAgentStateStore.javaL181-208 (ensureVersionColumn())agentscope-extensions-postgresql/.../state/PostgresAgentStateStore.java(same method — see PostgresAgentStateStore executes ALTER TABLE even when createIfNotExist=false #3213)
Why this is reachable
The default table name collides exactly with the legacy module's. AbstractJdbcDialect L69 sets tablePrefix = "agentscope_", and SessionStateDialect.sessionStateTableName() returns "sessions", so the resolved name is agentscope_sessions — which is also MysqlAgentStateStore.DEFAULT_TABLE_NAME.
Since #2503's stated plan is for users to migrate off agentscope-extensions-mysql onto agentscope-extensions-jdbc, the migration path lands on precisely the table that needs the ALTER.
To Reproduce
- Run any release whose
agentscope_sessionstable predates theversioncolumn (i.e. a table created by an olderMysqlAgentStateStore). - Switch the dependency to
agentscope-extensions-jdbcand build aJdbcAgentStateStoreagainst the same MySQL database, withcreateIfNotExist=true. CREATE TABLE IF NOT EXISTS agentscope_sessions ...is a no-op — the table exists, no error is raised.- Call
save(...).MysqlDialect.sessionStateUpsert()(L124-137) issues:
INSERT INTO agentscope_sessions (session_id, state_key, item_index, state_data, version)
VALUES (?, ?, ?, ?, 1)
ON DUPLICATE KEY UPDATE state_data = VALUES(state_data), version = version + 1Error messages
java.sql.SQLSyntaxErrorException: Unknown column 'version' in 'field list'
Every other version-dependent statement is affected the same way: sessionStateSelectVersioned, sessionStateCasUpdate, sessionStateInsertVersioned.
Expected behavior
Following the shape suggested in #3213:
if (createIfNotExist) {
createTableIfNotExist();
ensureVersionColumn();
} else {
verifyTableExists();
verifyVersionColumnExists(); // fail fast, no DDL
}At minimum, verifyTableExists() should also check the required columns, so the failure surfaces as an actionable startup error instead of an opaque SQL error on the first write.
One detail worth carrying over: #3162 / #3165 established that backfilled rows must land on version = 1, not 0, because 0 is the "row absent" sentinel used by getVersioned(). The legacy MysqlAgentStateStore already encodes that (ADD COLUMN version BIGINT NOT NULL DEFAULT 1), so any new implementation should match it rather than reintroducing the DEFAULT 0 variant.
Environment
- AgentScope-Java Version:
main@5b99145 - Module:
agentscope-extensions-jdbc
Activity
oss-maintainer commentedon Sep 20, 2026
Issue Evaluation
Category:
bug| Status: Confirmed | Severity: highVerified against
main@5b99145. All five claims hold; this is the officially recommended migration path (agentscope-extensions-mysql/-postgresqlare@Deprecated(forRemoval = true)and point atagentscope-extensions-jdbc), and it fails deterministically for every pre-existing table.Root cause
JdbcAgentStateStore.java:76-85— the constructor only has two schema paths, and neither can add a missing column:grepover the module's main sources finds noALTER TABLE(the only occurrence is a comment at:289) and noADD COLUMN. The sibling stores do have the migration:MysqlAgentStateStore.java:178→ensureVersionColumn()at:181-209(ADD COLUMN version BIGINT NOT NULL DEFAULT 1, guarded by anINFORMATION_SCHEMA.COLUMNSprobe at:183), andPostgresAgentStateStore.java:134→:137-153(ADD COLUMN IF NOT EXISTS).Why the table is silently adopted
Default names collide exactly:
AbstractJdbcDialect.java:69(tablePrefix = "agentscope_") resolved at:99-103, plusSessionStateDialect.java:42-44("sessions") →agentscope_sessions, which isMysqlAgentStateStore.DEFAULT_TABLE_NAME(:72).CREATE TABLE IF NOT EXISTSon the legacy table is a no-op, then the first write (save()→MysqlDialect.sessionStateUpsert():124-137, which namesversionand doesversion = version + 1) raises MySQL error 1054Unknown column 'version' in 'field list', wrapped asRuntimeException("Failed to save state: ...")atJdbcAgentStateStore.java:146. Same forgetVersioned()(:215-226) andreadVersion()(:240-245).Blast radius is partial, which is worth stating in the report
Unversioned statements (
SessionStateDialect.java:64-74,:117-125) do not touchversion, so plainget()/getList()keep working. Reads succeed while every write fails — that combination tends to hide the cause in production.Two corrections / nuances
sessionStateInsertIfAbsent(:83-94),sessionStateUpdateIfVersion(:97-114),sessionStateSelectVersioned(:128-136) andMysqlDialect.sessionStateUpsert— there is nosessionStateCasUpdate/sessionStateInsertVersioned. The conclusion is unaffected.#3165is not referenced in-repo, andJdbcAgentStateStore.java:287-293tolerates a0-backfilled row via its CAS fallback, so theDEFAULT 1rule here is sentinel correctness (0= "row absent",AgentStateStore.java:101-102,VersionedState.java:23-24) rather than crash prevention. Regression tests for [Bug]: ensureVersionColumn() backfills version=0, the same sentinel getVersioned() uses for "row absent" — every pre-existing session hits a phantom CAS conflict after upgrading #3162 exist in all three modules (MysqlAgentStateStoreTest.java:184-190,PostgresAgentStateStoreTest.java:493,JdbcAgentStateStoreH2Test.java:262-264) — any new migration must keepDEFAULT 1.Fix direction
SessionStateDialect.sessionStateEnsureVersionColumnDdl(), returning MySQL'sALTER TABLE %s ADD COLUMN version BIGINT NOT NULL DEFAULT 1and Postgres'ADD COLUMN IF NOT EXISTSvariant; no-op for fresh-schema vendors (H2 / SQLite).JdbcAgentStateStoreon thecreateIfNotExist=truepath; MySQL needs theINFORMATION_SCHEMA.COLUMNSprobe first because it has noIF NOT EXISTSforADD COLUMN(see also PostgresAgentStateStore executes ALTER TABLE even when createIfNotExist=false #3213 for why unconditionally executed DDL breaks DML-only roles).createIfNotExist=falsepath, add a read-onlyverifyVersionColumnExists()that fails fast at startup with an exception quoting the exact migration DDL, instead of an opaque SQL error on first write.version), build the store, then perform the first write andgetVersioned(); plus an idempotency test asserting a second construction issues noALTER.Related: #3213 (same
ensureVersionColumnfamily, DDL-permission angle), #3217 (case-insensitive key collation on the same tables), #3162/#3165 (version sentinel).If you'd like an automated fix PR from this direction, reply
/approve. For a different approach — e.g. scoping the migration to MySQL only, or making the table prefix collision itself an error — reply/revise <what to change>. To skip, reply/reject.Automated evaluation by github-manager-bot
aiyili commentedon Sep 22, 2026
Hi, I would like to work on this issue, following the evaluation's fix direction:
SessionStateDialect.sessionStateEnsureVersionColumnDdl()— MysqlDialect returnsALTER TABLE %s ADD COLUMN version BIGINT NOT NULL DEFAULT 1(probe-first, since MySQL has noADD COLUMN IF NOT EXISTS), PostgresDialect theIF NOT EXISTSvariant; H2/SqliteDialect keep the empty default (their tables can only originate from this module's CREATE TABLE, which already hasversion).DEFAULT 1preserved per the sentinel-correctness note.sessionStateCheckVersionColumnExists(tableName)probe next to the existingsessionStateCheckTableExists. One nuance: on H2 unquoted identifiers are stored uppercase, so the probe comparesUPPER(TABLE_NAME) = UPPER(?) AND UPPER(COLUMN_NAME) = 'VERSION'(verified empirically against H2 2.1.212); MySQL addsTABLE_SCHEMA = DATABASE(), Postgrestable_schema = current_schema().createIfNotExist=trueruns the migration afterCREATE TABLE IF NOT EXISTS;falsefails fast with an IllegalStateException quoting the exact DDL — same shape as PostgresAgentStateStore executes ALTER TABLE even when createIfNotExist=false #3213.version) round-trips first write +getVersioned()after migration; second construction issues noALTER(idempotency); verify-path failure message quotes the DDL.PR coming shortly.
fix(jdbc): 补齐 version 列迁移,从废弃 mysql/postgresql 模块迁入不再报 Unknown column
oss-maintainer commentedon Sep 23, 2026
Status: 72 h feedback window expired — no automated PR will be generated, the proposal window here is closed
The evaluation CTA above (
5750304882, posted 2026-09-20T14:07:56Z) reached its 72-hour feedback limit at 2026-09-23T14:07:56Z with no own-line/approve,/revise, or/rejectcommand in the thread, so per our workflow we skip PR generation and no competing PR will be filed from this proposal window. No action is needed from anyone.This is a timing stand-down, not a verdict on the report — and in this case the fix path is already owned by the community:
5770048378), with a four-part plan: a dialect-levelsessionStateEnsureVersionColumnDdl()(MySQL probe-first, PostgresIF NOT EXISTS, H2/SQLite keeping the empty default), a read-only version-column existence probe, running the migration undercreateIfNotExist=trueand failing fast with the exact DDL otherwise, plus legacy-shape migration and idempotency tests.OPENand unmerged at headd747b89df6(last updated 2026-09-22T02:48:10Z), so it remains the active carrier for this issue and the fix lands through it rather than through a bot-generated PR.Measured on the thread at 2026-09-23T14:09Z: 2 comments in total, 1 of them a non-bot reply after the CTA, and that reply carries no own-line directive token — so there was nothing for us to act on within the window.
The evaluation itself stands as recorded:
JdbcAgentStateStore.java:76-85offers only theCREATE TABLE IF NOT EXISTSpath and the existence-probe path, the module's main sources contain noALTER TABLE/ADD COLUMN, so a pre-existing table without aversioncolumn is adopted and then fails on first write — while the MySQL (ensureVersionColumn(),MysqlAgentStateStore.java:181-209) and Postgres (:137-153) siblings do carry the migration.If a maintainer would still prefer an independent, bot-generated PR for this fix despite #3244, leave a one-line approve on this issue and the spec will be regenerated.
Automated by github-manager-bot
aiyili commentedon Sep 24, 2026
Following up on the 72 h stand-down: the fix is already in flight as #3244 (#3244), still open and ready for review when a maintainer has a moment.
Scope, matching the evaluation:
sessionStateEnsureVersionColumnDdl()is added across the vendors -- MySQL probesINFORMATION_SCHEMA.COLUMNSfirst and only emitsALTERwhen the column is missing, Postgres usesADD COLUMN IF NOT EXISTS, H2/SQLite keep the empty default (no DDL needed).createIfNotExist=true; on thefalsepath the store fails fast with the exact DDL to apply via the user's own migration process.versioncolumn) migration and the idempotency of the already-migrated path.Happy to rebase onto current
mainbefore merge if needed.refactor: inline executeUpsert and simplify readVersion in JdbcAgentS…
refactor: inline executeUpsert and simplify readVersion in JdbcAgentS…
refactor: inline executeUpsert and simplify readVersion in JdbcAgentS…
refactor: inline executeUpsert and simplify saveIfVersion in JdbcAgen…
refactor: lift UNVERSIONED write out of the CAS branch in saveIfVersion
Refactor: separate the UNVERSIONED write path from the CAS branch in …
refactor(extensions): Consolidate JDBC table creation and column vali…