He-Pin opened a new issue, #3212:
URL: https://github.com/apache/pekko/issues/3212
### Motivation
当 PersistentActor 的 `RecoveryCompleted` 处理逻辑抛出异常时,actor
不会停止,而是被默认监督策略重启。这可能导致 actor 处于不一致的状态。
### 当前代码行为
`Eventsourced.scala` 中的 recovery 完成处理:
```scala
// Eventsourced.scala:779-789
try Eventsourced.super.aroundReceive(recoveryBehavior, RecoveryCompleted)
finally transitToProcessingState()
```
当用户的 `RecoveryCompleted` handler 抛异常时,异常传播到外层 try-catch(约 810-814 行),只调用
`returnRecoveryPermit()` 再 rethrow。没有 `context.stop(self)` 调用。
对比 `ReplayedMessage` 失败处理(772-778 行)和 `ReplayMessagesFailure`(790-794
行),这些路径有明确的错误处理逻辑。
### 预期行为
当 `RecoveryCompleted` 处理失败时,actor 应该停止(类似 replay 失败的行为),因为 recovery
阶段已经完成但用户初始化逻辑失败,重启会导致重复 recovery。
### 代码证据
-
`persistence/src/main/scala/org/apache/pekko/persistence/Eventsourced.scala:779-814`
— RecoveryCompleted 处理和外层异常捕获
-
`persistence/src/main/scala/org/apache/pekko/persistence/Eventsourced.scala:772-794`
— 对比其他 replay 失败路径的处理方式
### 复现方式
```scala
class FailingActor extends PersistentActor {
override def receiveRecover: Receive = {
case RecoveryCompleted => throw new RuntimeException("init failed")
}
override def receiveCommand: Receive = { case _ => }
}
// 预期: actor 停止
// 实际: actor 被重启,重复 recovery,再次失败,循环
```
### 影响范围
- 模块:`pekko-persistence`
- 影响在 `RecoveryCompleted` 中做初始化(如资源分配、状态验证)的用户代码
- 可能导致 actor 陷入无限重启循环
--
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]