nzw921rx commented on code in PR #13243: URL: https://github.com/apache/seatunnel/pull/13243#discussion_r4549975363
########## docs/zh/connectors/common-options/sink-common-options.md: ########## @@ -19,11 +19,26 @@ sidebar_position: 4 |--------------|--------|------|-----| | plugin_input | list | 否 | - | | metadata_datasource_id | string | 否 | - | +| multi_table_sink_replica | int | 否 | 1 | ### metadata_datasource_id [string] 用于从元数据中心获取连接配置的数据源 ID。当指定此参数时,连接器将从外部元数据服务获取连接详细信息(如 URL、用户名、密码),而不是使用直接配置。详见 [元数据 SPI](../../introduction/concepts/metadata-spi.md)。 +### multi_table_sink_replica [int] + +多表 Sink 在一个子任务中为每张表运行的 writer 数量,默认值为 1。取值大于 1 时,一张表的记录会被分配到 +它的多个 writer 上,因此 writer 必须通过 `SupportMultiTableSinkWriter.replicaMode()` 声明如何安全地分配: + +- `KEYED`:按 `primaryKey()` 给出的键路由,同一键的所有变更按顺序到达同一个 writer。声明该模式但没有键的 + writer 会被拒绝。Jdbc 声明该模式(`is_exactly_once` 除外),因此 Jdbc 表需要在表结构或 `primary_keys` + 中有主键。 +- `RANDOM`:记录可以分配到任意 writer,只适用于写入结果与写入顺序无关的 writer。 +- `UNSUPPORTED`(默认):创建或恢复 writer 时作业失败,错误信息会给出表、连接器和 writer 类。此类 + Sink 请将该选项设置为 1。 + +各连接器在 [#13223](https://github.com/apache/seatunnel/issues/13223) 中逐个验证并声明。 Review Comment: I think we don't need to expose relevant issue links in the document? ########## docs/zh/architecture/features/multi-table.md: ########## @@ -182,16 +185,30 @@ sink { # 多表配置 multi_table_sink_replica = 4 # 写入器副本数(对所有表生效) + # Jdbc 按主键路由副本,因此每张表都需要主键(来自表结构或 primary_keys) } } ``` +只有当每张表的 writer 都通过 `SupportMultiTableSinkWriter.replicaMode()` 声明了记录如何在副本间分配时, +才允许大于 1 的取值;否则作业会在写入任何记录之前失败: + Review Comment: Do I understand that only the behavior of the replica pattern needs to be described here? No need to expose the implementation related to connectors? ########## docs/zh/introduction/concepts/incompatible-changes.md: ########## @@ -4,6 +4,13 @@ ## dev +### 多表 Sink:`multi_table_sink_replica` 大于 1 时需要声明副本模式 + +- **行为变更:`multi_table_sink_replica` 大于 1 时,writer 未声明副本模式的 Sink 会被拒绝** + - **描述**:`multi_table_sink_replica` 大于 1 时,多表 Sink 会在一个子任务中为每张表运行多个 writer。除 Jdbc 外,所有连接器的 writer 都没有键,因此记录会被随机分配到这些 writer 上,同一条记录的两次变更可能乱序生效:旧值可能覆盖新值,已删除的行也可能重新出现。单表作业中没有 tableId 的记录,即使表有键,也会被随机分配。现在 writer 通过 `SupportMultiTableSinkWriter.replicaMode()` 声明副本模式:`KEYED` 按 `primaryKey()` 给出的键路由,`RANDOM` 允许随机路由,默认的 `UNSUPPORTED` 拒绝多个副本。Jdbc 声明 `KEYED`,而 `KEYED` 需要键,因此没有主键的 Jdbc 表不能使用多个副本。详见 [#13223](https://github.com/apache/seatunnel/issues/13223)。 Review Comment: I think there is no need to expose the issue link for the same issue -- 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]
