Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WFMySQLConnection 出现崩溃 #1365

Closed
18328594608 opened this issue Sep 7, 2023 · 9 comments
Closed

WFMySQLConnection 出现崩溃 #1365

18328594608 opened this issue Sep 7, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@18328594608
Copy link

崩溃堆栈如下:

#0 ComplexMySQLTask::finish_once (this=0xffffd4004340) at /home/parallels/workspace/codespace/deal_server/wfrest/workflow/src/factory/MySQLTaskImpl.cc:750
#1 0x0000fffff7f2b8b0 in WFComplexClientTask<protocol::MySQLRequest, protocol::MySQLResponse, bool>::done (this=0xffffd4004340) at /home/parallels/workspace/codespace/deal_server/wfrest/workflow/src/factory/WFTaskFactory.inl:421
#2 0x0000fffff7ef7af8 in SubTask::subtask_done (this=this@entry=0xffffd4003f40) at /home/parallels/workspace/codespace/deal_server/wfrest/workflow/src/kernel/SubTask.cc:29
#3 0x0000fffff7f30124 in WFResolverTask::dispatch (this=0xffffd4003f40) at /home/parallels/workspace/codespace/deal_server/wfrest/workflow/src/nameservice/WFDnsResolver.cc:390
#4 0x0000aaaaaaba1158 in WFServerTask<wfrest::HttpReq, wfrest::HttpResp>::Processor::dispatch (this=0xffff80000f60) at /home/parallels/workspace/codespace/deal_server/wfrest/workflow/_include/workflow/WFTask.inl:188
#5 0x0000aaaaaaba0f50 in WFServerTask<wfrest::HttpReq, wfrest::HttpResp>::handle (this=0xffff80000be0, state=3, error=0) at /home/parallels/workspace/codespace/deal_server/wfrest/workflow/_include/workflow/WFTask.inl:245
#6 0x0000fffff7ef539c in Communicator::handle_incoming_request (this=0xfffff7f705a0 <__CommManager::get_instance()::kInstance+8>, res=0xffff80000b70) at /home/parallels/workspace/codespace/deal_server/wfrest/workflow/src/kernel/Communicator.cc:669
#7 0x0000fffff7ef7504 in Communicator::handler_thread_routine (context=context@entry=0xfffff7f705a0 <__CommManager::get_instance()::kInstance+8>) at /home/parallels/workspace/codespace/deal_server/wfrest/workflow/src/kernel/Communicator.cc:1165
#8 0x0000fffff7ef2b20 in __thrdpool_routine (arg=0xaaaaaacba8e0) at /home/parallels/workspace/codespace/deal_server/wfrest/workflow/src/kernel/thrdpool.c:63
#9 0x0000fffff7b1d5c8 in start_thread (arg=0x0) at ./nptl/pthread_create.c:442
#10 0x0000fffff7b85d1c in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:79

在这个函数中,target->state = 0; 此时target地址为0xffffffffffffffef 无效值。
使用的sql 客户端为WFMySQLConnection new WFMySQLConnection(1);
后续采用 WFMySQLTask *mysql_task = _m_conn->create_query_task(sql,[func](WFMySQLTask *mysql_task)
{
nlohmann::json json = mysql_concat_json_res(mysql_task);
func(&json);
});
mysql_task->start(); 这个函数进行操作 ,在压测时出现崩溃,压力大概为每秒1000个请求。
另外task 在运行中出现errmsg=Resource temporarily unavailable 这个报错 是为什么。

@Barenboim
Copy link
Contributor

你好,感谢报bug。请问是最新的0.10.9代码吗?

@Barenboim
Copy link
Contributor

Barenboim commented Sep 7, 2023

errmsg=Resource temporarily unavailable 这个问题,是你不同的mysql connection用了相同的id,就是构造函数里转的那个整数。不同的connection,id必须是不同的。

@18328594608
Copy link
Author

可是我只用了一个 WFMySQLConnection* _m_conn;对象,所有的sql请求都是通过它来发放的,只有_m_conn 这个对象connection 没有不同的mysql connection

@18328594608
Copy link
Author

你好,感谢报bug。请问是最新的0.10.9代码吗?

是的,我今天clone下来的最新的代码
另外 更改了一下代码WFMySQLTask *mysql_task = WFTaskFactory::create_mysql_task 使用这个task的方式去执行sql之后没有出现过崩溃问题,崩溃原因应该就在WFMySQLConnection 这个对象的调用里面了

@Barenboim
Copy link
Contributor

如果你不是为了做事务,没有必要用mysql connection啊?你直接:

WFMySQLTask *task = WFTaskFactory::create_mysql_task(...);

mysql connection一般只用在事务的场合,需要把所有的请求固定在一个连接上发送,使用的时候不可以把connection上的两个任务并行启动,否则就有可能出现EAGAIN错误。你这种高并发的mysql请求,直接从一级工厂WFTaskFactory创建mysql任务就可以了。

@Barenboim
Copy link
Contributor

你好,感谢报bug。请问是最新的0.10.9代码吗?

是的,我今天clone下来的最新的代码 另外 更改了一下代码WFMySQLTask *mysql_task = WFTaskFactory::create_mysql_task 使用这个task的方式去执行sql之后没有出现过崩溃问题,崩溃原因应该就在WFMySQLConnection 这个对象的调用里面了

我看一下这个崩溃可能的原因。

@Barenboim Barenboim added the bug Something isn't working label Sep 7, 2023
@Barenboim
Copy link
Contributor

这真是个教训,空指针静态转换的结果,不一定还是空。修改:#1366
只有在mysql connection用法不太正确的情况下会出现。

@18328594608
Copy link
Author

感谢回复.
我更新下这个pr

@Barenboim
Copy link
Contributor

你直接用WFTaskFactory创建任务就可以了,不会受这个问题的影响。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants