He-Pin opened a new issue, #3217:
URL: https://github.com/apache/pekko/issues/3217
### Motivation
`AsyncWriteJournal` 的 `asyncReplayMessages` 在回放事件时没有背压机制,对于拥有大量事件的持久化
actor,回放时可能将百万级事件直接发送到 actor mailbox,导致 OutOfMemoryError。
### 当前代码行为
`AsyncWriteJournal.scala` 中:
```scala
// AsyncWriteJournal.scala:190-195
asyncReplayMessages(persistenceId, fromSequenceNr, toSequenceNr, max) {
adaptedPersistentRepr =>
replyTo.tell(ReplayedMessage(adaptedPersistentRepr), ActorRef.noSender)
}
```
replay 回调直接
`tell(ReplayedMessage(...))`,无任何背压或流量控制。`ReplayFilter`(`journal/ReplayFilter.scala:85-88`)仅提供了小的
`windowSize` buffer,但基础 API 本身无流量控制。
### 预期行为
replay 应该有流量控制机制,例如批量回放、等待确认后再继续,或限制 in-flight 消息数量,避免大量事件涌入 mailbox。
### 代码证据
-
`persistence/src/main/scala/org/apache/pekko/persistence/journal/AsyncWriteJournal.scala:190-195`
— replay 回调无背压
-
`persistence/src/main/scala/org/apache/pekko/persistence/journal/ReplayFilter.scala:85-88`
— ReplayFilter 仅小窗口 buffer
### 复现方式
创建一个拥有百万级事件的 PersistentActor,触发 recovery,观察内存使用和 mailbox 大小。
### 影响范围
- 模块:`pekko-persistence`
- 影响拥有大量事件日志的持久化 actor
- 生产环境中的长期运行 actor 恢复时可能 OOM
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]