Repository navigation
Conversation
JingsongLi
left a comment
There was a problem hiding this comment.
The startup repair addresses a real recovery case after a MySQL table replacement. I ran 101 schema and Flink CDC tests locally on this commit. The Flink 1 CI job also passed both MySQL sync integration suites. Flink 1 CDC CI
| validateChanges(table, identifier, changes); | ||
| try { | ||
| catalog.alterTable(identifier, changes, false); | ||
| } catch (Catalog.ColumnAlreadyExistException | ConcurrentModificationException e) { |
There was a problem hiding this comment.
[P1] Reload the schema after a REST version conflict
If an operator runs a concurrent ALTER TABLE after the CDC action loads the target, SchemaManagerUtils raises ConcurrentModificationException for the stale version. The repository's REST test server maps this exception to HTTP 500, which the REST client handles outside this catch. The job submission therefore fails before it can reload and retry, even with a server that accepts the new action. Please define a version-conflict response that survives the REST round trip and add an integration test that advances the schema between the GET and ALTER.
There was a problem hiding this comment.
Thanks for the review. Fixed by adding a 409 + SCHEMA response for version conflicts and an integration test to verify schema reload and retry.
| @JsonSubTypes({ | ||
| @JsonSubTypes.Type( | ||
| value = SchemaChange.CheckSchemaVersion.class, | ||
| name = SchemaChange.Actions.CHECK_SCHEMA_VERSION_ACTION), |
There was a problem hiding this comment.
[P2] Add the version check to the REST ALTER schema
Startup evolution sends this action as the first entry in AlterTableRequest.changes. I checked docs/static/rest-catalog-open-api.yaml and found that both the schema-change union and its discriminator exclude checkSchemaVersion. A client or gateway that validates against the published contract will reject the entire batch. Please add the action and its required int64 schemaId to the OpenAPI definition and verify a whole ALTER request against it.
There was a problem hiding this comment.
Fixed by adding checkSchemaVersion to the OpenAPI spec.
JingsongLi
left a comment
There was a problem hiding this comment.
I verified the schema-version conflict retry, MySQL 5.7 savepoint restore, and database sync in both modes. All 112 focused tests passed on the integration with master (2be2aed46d).
| private final long schemaId; | ||
|
|
||
| @JsonCreator | ||
| private CheckSchemaVersion(@JsonProperty(FIELD_SCHEMA_ID) long schemaId) { |
There was a problem hiding this comment.
[P2] Require an explicit integer schema version before applying ALTER
The published schema requires an integer schemaId. I sent an ALTER containing checkSchemaVersion followed by addColumn to the REST test service with a target at schema version 0. A missing schemaId, null, 0.5, and "0" each decoded as 0, returned HTTP 200, and committed the added column. An explicit 1 returned 409 SCHEMA and left the table at version 0. Please validate the presence and integer type at deserialization, and cover the bad-request response and unchanged schema in the HTTP test.
Purpose
MySQL CDC jobs fail at startup when the source schema drifted from the
Paimon table (e.g. a shadow table was renamed into place but the schema
change never reached Paimon). Recovery currently requires manual ALTERs.
Add an opt-in
--add_missing_columns_on_startupoption tomysql_sync_table / mysql_sync_database. During job submission the action
reads the current MySQL schema through JDBC, applies the configured type
mappings, then for each Paimon table:
- appends missing source columns as nullable fields (never outside
primary/partition/bucket keys), so historical rows read as NULL;
- widens compatible existing columns (VARCHAR/INT/PI precision, decimal
with preserved integer range, honoring decimal-no-change) while
keeping the target's existing nullability and any already-wider type;
- rejects incompatible changes before touching the table and commits all
additions/updates of a table as a single schema version.
To make the batch safe under concurrent schema edits, introduce the
SchemaChange.checkSchemaVersionchange in paimon-api/paimon-core: theschema build fails with ConcurrentModificationException if the table moved
past the version used for validation. On conflict the action reloads the
table, recomputes and retries (up to two retries). This is guarded so the
existing single-table atomicity and the
--ignore_incompatiblebehaviorof database sync are preserved. Docs updated in mysql-cdc.mdx, including
the note that REST Catalog services must support checkSchemaVersion and
that cross-table updates are sequential (not atomic across tables).
See the error message: " java.lang.IllegalArgumentException:Incompatible schema found."
Tests
#testCheckSchemaVersionEquality
#testStaleSchemaVersionPreventsPartialCommit (verifies no partial commit)
widening, decimal integer-range/decimal-no-change, key exclusion,
concurrent add/drop/rename reload and retry, last-retry conflict keeps
original exception as suppressed, per-table atomicity)
(DIVIDED/COMBINED), #testWidenColumnsOnStartup,
#testStartupRepairKeepsWiderTargetType,
#testStartupRepairIgnoresIncompatibleTable;
MySqlSyncTableActionITCase#testAddMissingColumnsOnStartupAfterRename,
#testRestoreSavepointAfterAddingMissingColumnsOnStartup,
#testWidenColumnsOnStartupAfterRename,
#testIncompatibleStartupTypeChangeDoesNotAddMissingColumns