Kafka Streams:使用 at_least_once 时,对保存到状态存储的排序有任何保证吗?
Kafka Streams: Any guarantees on ordering of saves to state stores when using at_least_once?
我们有一个使用处理器 API 构建的 Kafka Streams Java 拓扑。
在拓扑中,我们有一个处理器,它保存到多个状态存储。
当我们使用 at_least_once 时,我们预计会看到状态存储之间的一些不一致 - 例如传入的记录导致同时写入状态存储 A 和 B,但是保存之间的崩溃导致只有存储 A 的保存被写入 Kafka 更改日志主题。
我们能保证我们保存的顺序也是写入状态存储的顺序吗?例如。如果我们先保存到存储 A,然后再保存到存储 B,我们当然可以有写入两个更改日志都成功的情况,以及只有写入更改日志 A 完成的情况——但我们是否也可以以只有write to change log B完成的情况?
什么情况会导致重放?当然是崩溃——但是重新平衡、新的代理分区领导者,或者当我们收到 "Offset commit failed" 错误(请求超时)时呢?
不久前,我们尝试使用 exactly_once,结果出现了很多错误消息,我们无法理解。 exactly_once 会给我们跨多个状态存储的原子写入吗?
广告 3。根据 The original design document on exactly-once support in Kafka Streams,我认为 eaxctly_once
您可以跨多个状态存储进行原子写入
When stream.commit() is called, the following steps are executed in order:
- Flush local state stores (KTable caches) to make sure all changelog records are sent downstream.
- Call producer.sendOffsetsToTransactions(offsets) to commit the current recorded consumer’s positions within the transaction. Note that although the consumer of the thread can be shared among multiple tasks hence multiple producers, task’s assigned partitions are always exclusive, and hence it is safe to just commit the offsets of this tasks’ assigned partitions.
- Call producer.commitTransaction() to commit the current transaction. As a result the task state represented as the above triplet is committed atomically.
- Call producer.beginTransaction() again to start the next transaction.
我们有一个使用处理器 API 构建的 Kafka Streams Java 拓扑。
在拓扑中,我们有一个处理器,它保存到多个状态存储。
当我们使用 at_least_once 时,我们预计会看到状态存储之间的一些不一致 - 例如传入的记录导致同时写入状态存储 A 和 B,但是保存之间的崩溃导致只有存储 A 的保存被写入 Kafka 更改日志主题。
我们能保证我们保存的顺序也是写入状态存储的顺序吗?例如。如果我们先保存到存储 A,然后再保存到存储 B,我们当然可以有写入两个更改日志都成功的情况,以及只有写入更改日志 A 完成的情况——但我们是否也可以以只有write to change log B完成的情况?
什么情况会导致重放?当然是崩溃——但是重新平衡、新的代理分区领导者,或者当我们收到 "Offset commit failed" 错误(请求超时)时呢?
不久前,我们尝试使用 exactly_once,结果出现了很多错误消息,我们无法理解。 exactly_once 会给我们跨多个状态存储的原子写入吗?
广告 3。根据 The original design document on exactly-once support in Kafka Streams,我认为 eaxctly_once
您可以跨多个状态存储进行原子写入
When stream.commit() is called, the following steps are executed in order:
- Flush local state stores (KTable caches) to make sure all changelog records are sent downstream.
- Call producer.sendOffsetsToTransactions(offsets) to commit the current recorded consumer’s positions within the transaction. Note that although the consumer of the thread can be shared among multiple tasks hence multiple producers, task’s assigned partitions are always exclusive, and hence it is safe to just commit the offsets of this tasks’ assigned partitions.
- Call producer.commitTransaction() to commit the current transaction. As a result the task state represented as the above triplet is committed atomically.
- Call producer.beginTransaction() again to start the next transaction.