Skip to content

[BUG] 如何改造示例连接池以支持 amphp 的异步 redis/mysql? #1116

@hightman

Description

@hightman

运行环境为最新的 workerman/5.1 和 webman 框架, eventloop 采用 PHP8 自带的 Fiber 协程模式。

尝试根据官网连接池文档示例编写连接池去支持 amphp/redis, amphp/mysql 这些异步客户端,当并发数超过 max_connections 会在归还连接时抛出以下错误:

FiberError: Cannot switch fibers in current execution context

这个情况初步判断是因为 Coroutine::defer() 归还连接的调用发生在析构函数,异步客户端的纤程切换导致了异常。

示例代码我就不贴了,估计作者一看便知。

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions