He-Pin opened a new issue, #3223: URL: https://github.com/apache/pekko/issues/3223
### Motivation TCP stream 的 `TcpStreamLogic` 在正常终止路径(Terminated/Closed/ConfirmedClosed/ErrorClosed)中有 fail/completeStage 处理,但底层 socket 的文件描述符释放依赖 `connection` ActorRef 的生命周期。在特定超时路径下,可能导致文件描述符泄漏。 ### 当前代码行为 `TcpStages.scala` 中 `TcpStreamLogic`(252-512 行)处理各种关闭事件: - `Terminated` → fail stage - `Closed` → completeStage - `ConfirmedClosed` → completeStage - `ErrorClosed` → fail stage `postStop()`(509 行)报告异常。但底层 socket 关闭依赖 `connection` ActorRef 被 GC 回收。如果 actor 终止链中存在延迟或异常路径,fd 可能暂时泄漏。 ### 预期行为 无论何种关闭路径,底层 socket 应该被显式关闭,不依赖 ActorRef 的 GC 行为。 ### 代码证据 - `stream/src/main/scala/org/apache/pekko/stream/impl/io/TcpStages.scala:252-512` — TcpStreamLogic 终止处理 - `stream/src/main/scala/org/apache/pekko/stream/impl/io/TcpStages.scala:509` — postStop 实现 ### 复现方式 高并发 TCP 连接场景,频繁建立和断开连接,用 `lsof` 或 `/proc/<pid>/fd` 监控文件描述符数量。 ### 影响范围 - 模块:`pekko-stream` - 影响高并发 TCP 连接场景 - 长期运行可能导致 fd 耗尽(Too many open files) ### 备注 此问题需要运行时验证。静态分析无法确认所有超时路径的 fd 释放行为。建议通过压力测试 + fd 监控确认。 -- 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]
