wgzhao opened a new issue, #13458: URL: https://github.com/apache/seatunnel/issues/13458
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3Abug) and found no similar issues. ### What happened When a JDBC sink batch fails, the user-facing exception contains only the column name reported by the driver. Neither the target database nor the target table is included, so in multi-table jobs it is impossible to tell which table failed without guessing. For example, a MySQL charset error ends up as: ``` java.lang.RuntimeException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: org.apache.seatunnel.connectors.seatunnel.jdbc.exception.JdbcConnectorException: ErrorCode:[COMMON-10], ErrorDescription:[Flush data operation that in sink connector failed] ... Caused by: java.sql.BatchUpdateException: Incorrect string value: '\xF0\x9F\x87\xA8\xF0\x9F...' for column 'follower_name' at row 156 ``` `follower_name` is a column, but there is no `db.table` information anywhere in the chain. The sink actually knows the table at every layer, it is just dropped while wrapping the exception: 1. `JdbcOutputFormat` has no `TablePath`/table identifier field. Batch failures are wrapped without any table context: - `JdbcOutputFormat.java:252`, `:278`, `:284` -> `new JdbcConnectorException(FLUSH_DATA_FAILED, e)` (the `COMMON-10` above) - `checkFlushException()` at `JdbcOutputFormat.java:133` -> `"Writing records to JDBC failed."` 2. `JdbcSinkWriter` holds `sinkTablePath` (`JdbcSinkWriter.java:126`) but does not use it in the `prepareCommit`/`close` error messages: - `JdbcSinkWriter.java:427` -> `"commit failed," + e.getMessage()` - `JdbcSinkWriter.java:435` -> `new JdbcConnectorException(FLUSH_DATA_FAILED, "prepare commit failed", e)` 3. `MultiTableSinkWriter.prepareCommit` iterates per table and has the sink table path via `sinkWriterEntry.getKey().getTableIdentifier()` (built from `TablePath.toString()` in `MultiTableSink.java:150`), but the fail-fast path discards it: - `MultiTableSinkWriter.java:789`, `:792` -> `throw new RuntimeException(error)` - `MultiTableSinkWriter.java:821` -> `future.get()` wrapped as `new RuntimeException(e)` The write/queue path already includes the table id (`"table %s sink throw error"`, `MultiTableSinkWriter.java:345`), so the checkpoint/flush path is inconsistent with the write path. ### SeaTunnel Version The stack trace line numbers match 2.3.10–2.3.12. The same wrapping code is still present on the latest `dev` (commit `3eefbe6f08`, 2026-11-26), so the issue is not fixed there. ### SeaTunnel Config Representative configuration shape (credentials removed; the exact reporter config is not available, but the problem is in the shared JDBC error-wrapping code, not in a specific option): ```hocon env { parallelism = 1 job.mode = "BATCH" } source { Jdbc { url = "jdbc:mysql://source-host:3306/source_db" driver = "com.mysql.cj.jdbc.Driver" user = "******" password = "******" query = "select id, follower_name from t1" } } sink { Jdbc { url = "jdbc:mysql://sink-host:3306/sink_db" driver = "com.mysql.cj.jdbc.Driver" user = "******" password = "******" database = "sink_db" table = "t1" generate_sink_sql = true } } ``` In a multi-table job every table produces the same message, so this becomes much harder to diagnose. ### Running Command ```shell sh bin/seatunnel.sh --config config/jdbc-to-jdbc.conf -e local ``` ### Error Exception ```log java.lang.RuntimeException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: org.apache.seatunnel.connectors.seatunnel.jdbc.exception.JdbcConnectorException: ErrorCode:[COMMON-10], ErrorDescription:[Flush data operation that in sink connector failed] at org.apache.seatunnel.engine.server.task.flow.SinkFlowLifeCycle.received(SinkFlowLifeCycle.java:304) ... at java.base/java.lang.Thread.run(Thread.java:840) Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: org.apache.seatunnel.connectors.seatunnel.jdbc.exception.JdbcConnectorException: ErrorCode:[COMMON-10], ErrorDescription:[Flush data operation that in sink connector failed] at org.apache.seatunnel.api.sink.multitablesink.MultiTableSinkWriter.prepareCommit(MultiTableSinkWriter.java:305) at org.apache.seatunnel.engine.server.task.flow.SinkFlowLifeCycle.received(SinkFlowLifeCycle.java:203) ... 17 more Caused by: java.util.concurrent.ExecutionException: org.apache.seatunnel.connectors.seatunnel.jdbc.exception.JdbcConnectorException: ErrorCode:[COMMON-10], ErrorDescription:[Flush data operation that in sink connector failed] at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191) at org.apache.seatunnel.api.sink.multitablesink.MultiTableSinkWriter.prepareCommit(MultiTableSinkWriter.java:303) ... 18 more Caused by: org.apache.seatunnel.connectors.seatunnel.jdbc.exception.JdbcConnectorException: ErrorCode:[COMMON-10], ErrorDescription:[Flush data operation that in sink connector failed] at org.apache.seatunnel.connectors.seatunnel.jdbc.internal.JdbcOutputFormat.flush(JdbcOutputFormat.java:142) at org.apache.seatunnel.connectors.seatunnel.jdbc.sink.JdbcSinkWriter.prepareCommit(JdbcSinkWriter.java:193) at org.apache.seatunnel.api.sink.SinkWriter.prepareCommit(SinkWriter.java:75) at org.apache.seatunnel.api.sink.multitablesink.MultiTableSinkWriter.lambda$prepareCommit$4(MultiTableSinkWriter.java:288) ... 6 more Caused by: java.sql.BatchUpdateException: Incorrect string value: '\xF0\x9F\x87\xA8\xF0\x9F...' for column 'follower_name' at row 156 at com.mysql.cj.jdbc.exceptions.SQLError.createBatchUpdateException(SQLError.java:223) at com.mysql.cj.jdbc.ClientPreparedStatement.executeBatchWithMultiValuesClause(ClientPreparedStatement.java:716) at com.mysql.cj.jdbc.ClientPreparedStatement.executeBatchInternal(ClientPreparedStatement.java:407) at com.mysql.cj.jdbc.StatementImpl.executeBatch(StatementImpl.java:799) at org.apache.seatunnel.shade.com.zaxxer.hikari.pool.ProxyStatement.executeBatch(ProxyStatement.java:127) at org.apache.seatunnel.connectors.seatunnel.jdbc.internal.JdbcOutputFormat.flush(JdbcOutputFormat.java:136) ... 9 more ``` ### Zeta or Flink or Spark Version Zeta (SeaTunnel 2.3.x) ### Java or Scala Version JDK 17 (per the stack trace) ### Screenshots N/A ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) ### Additional context / suggested fix I am preparing a fix for this issue and plan to submit a PR. Proposed scope (no config, API or SPI compatibility impact): - Include the target table path in JDBC sink flush/commit failures, for example `Writing records to JDBC failed for table db_name.table_name`. The most direct approach is to plumb `sinkTablePath` through `JdbcOutputFormatBuilder` into `JdbcOutputFormat`, or wrap the exception once in `JdbcSinkWriter`, which already holds `sinkTablePath`. - Include the table id in `MultiTableSinkWriter.prepareCommit` fail-fast / `future.get()` wrapping, matching the write path behavior. - Apply the same enrichment to `JdbcExactlyOnceSinkWriter`. - Do not include the JDBC URL or credentials in the message; the table path is sufficient. -- 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]
