goutamadwant opened a new pull request, #13242: URL: https://github.com/apache/seatunnel/pull/13242
### Purpose of this pull request Part of #13223 (`JDBC / normal` row: key representation and key refresh after a schema change). The two gaps were noted in #13221. `MultiTableSinkWriter` routes a row to a replica queue by the hash of its primary key value. Two cases send rows of one key to different queues, so with `multi_table_sink_replica > 1` the `UPDATE_BEFORE`/`UPDATE_AFTER`/`DELETE` rows of one key run on different threads in arbitrary order: - `byte[]` keys (`BINARY`/`VARBINARY`) were hashed with the identity `hashCode()`. The router now hashes `byte[]` by content with `Arrays.hashCode`; other key types keep their existing hash, so routing for non-binary keys is unchanged. - The key position was read from each sub-writer once at construction, and `JdbcSinkWriter` kept it `final`. After `ADD COLUMN FIRST`/`AFTER` or `DROP COLUMN` ahead of the key, rows were hashed on another column. `JdbcSinkWriter` now keeps the key column name, follows a rename of that column and recomputes the position after `applySchemaChange` (a dropped key column leaves the writer unkeyed, with a warning), and the coordinator re-reads every live sub-writer's `primaryKey()` once the schema-change barrier has drained. Rows enqueued before the DDL keep their old queue because the barrier drains them first. Routing is not part of checkpoint state, so the change has no restore impact. The existing keyed hash and the capability contract planned in #13223 are untouched; this rebases onto Phase 1 once it lands. ### Does this PR introduce _any_ user-facing change? No. Rows with the same binary key, or the same key after a positional schema change, are now written in order by one sub-writer when `multi_table_sink_replica > 1`. ### How was this patch tested? - `MultiTableSinkWriterTest#testByteArrayPrimaryKeyRoutesEqualKeysToOneWriter` and `#testPrimaryKeyIndexIsRefreshedAfterSchemaChange` fail on dev (rows spread over writers, second row lands on another writer) and pass with the fix. - `JdbcSinkWriterPrimaryKeyIndexTest` (7 cases): add first, add after the key, drop before the key, rename the key column, restored schema with a renamed key, drop the key column, writer without a key. Four fail on dev and pass with the fix. - Full `seatunnel-api` (412 tests) and `connector-jdbc` (1292 tests, 6 skipped) unit suites pass on JDK 11 and JDK 17; `spotless:check` clean. - Not run: Docker E2E (`MysqlCDCWithSchemaChangeIT` with replicas > 1 would be the end-to-end check). ### Check list * [x] No new dependency * [x] No documentation change needed * [x] `incompatible-changes.md` not needed * [x] Not a connector addition -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
