branch-4.1: [fix](streaming-job) restore split-bound Java types when reading FE-persisted CDC offset #63219#63272
Merged
Merged
Conversation
…ersisted CDC offset (#63219) ### What problem does this PR solve? Issue Number: close #xxx Related PR: #xxx Problem Summary: PG streaming jobs with a temporal chunk-key column (e.g. `DATE` PK) fail during snapshot read with: ``` PSQLException: ERROR: operator does not exist: date <= character varying Hint: No operator matches the given name and argument types. ``` **Root cause** cdc_client reports snapshot splits to FE; FE persists the offset as JSON via Spring Jackson, where `SqlDateSerializer` writes `java.sql.Date` as a `"yyyy-MM-dd"` string. When the offset is later read back, `ObjectMapper.convertValue(offset, SnapshotSplit.class)` lands the bound values back into `Object[]` as `String` (type info is gone). At read time `PostgresQueryUtils.readTableSplitDataStatement` calls bare `statement.setObject(idx, splitEnd[i])`; PG JDBC sends `String` as VARCHAR oid, and PostgreSQL — strict about operator resolution — refuses `date <= varchar` (no implicit cast from varchar to date). The same FE round-trip happens for MySQL too. MySQL server is lenient enough to implicitly coerce the bound, so the surface error does not appear, but `SplitKeyUtils.compareObjects` falls back to `toString()` comparison whenever the restored type doesn't match the Debezium connect-schema type — a latent issue worth keeping consistent. **Fix** Restore the original Java types at the cdc_client side, where the loss happens: - `AbstractCdcSourceReader` adds: - abstract `probeSplitKeyClass(TableId, Column, JobBaseConfig)` — dialect-specific lookup - `resolveSplitKeyClass(...)` — per-column cached wrapper (1 probe per table.column, reused across splits) - static `convertBounds(Object[], Class<?>, ObjectMapper)` — restores Object[] elements to the target class - `PostgresSourceReader` / `MySqlSourceReader` override `probeSplitKeyClass`: run `SELECT col FROM table WHERE 1=0` and use `ResultSetMetaData.getColumnClassName(1)` so the JDBC driver itself decides the Java type. Probe failure throws (no silent fallback — silent fallback would let the original bug recur). - `JdbcIncrementalSourceReader.createSnapshotSplit` / `createStreamSplit` and `MySqlSourceReader.createSnapshotSplit` / `createBinlogSplit` (4 sites total) apply `convertBounds` before constructing Flink CDC's `SnapshotSplit` / `FinishedSnapshotSplitInfo`. - `convertBounds` special-cases `java.sql.Date` / `Timestamp` / `Time` via `valueOf` to match the JVM-default-TZ semantics of `rs.getObject` (Jackson's default `SqlDateDeserializer` hard-codes GMT, which would shift the value in non-UTC TZs). Other types fall through to `ObjectMapper.convertValue`. ### Release note Fix PG/MySQL streaming snapshot failing on temporal chunk-key columns after FE offset JSON round-trip strips the original Java type.
Member
|
run buildall |
yiguolei
approved these changes
May 20, 2026
Contributor
Author
|
PR approved by at least one committer and no changes requested. |
Contributor
Author
|
PR approved by anyone and no changes requested. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-picked from #63219