Skip to content

cygwin-x64版本PDO组件并发访问时程序崩溃 #5758

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

Closed
skyshore2001 opened this issue May 9, 2025 · 0 comments
Closed

cygwin-x64版本PDO组件并发访问时程序崩溃 #5758

skyshore2001 opened this issue May 9, 2025 · 0 comments

Comments

@skyshore2001
Copy link

skyshore2001 commented May 9, 2025

windows下使用版本为:Swoole 5.1.7 (cli) (built: Feb 22 2025 03:00:34) (NTS)
当开启一键协程时,通过PDO访问数据库在有并发时会程序崩溃,无任何输出信息。
简化测试程序如下:

<?php

// 开启协程后,并发访问程序崩溃!不加这句不出错,无并发仅一个连接访问不出错。
Co::set(['hook_flags'=> SWOOLE_HOOK_ALL]);

$server = new Swoole\Http\Server("0.0.0.0", 8081);
$server->set([
	'worker_num'=>1
]);

$server->on('Request', function ($req, $res) {
// 连接MySQL数据库操作
	$dsn = "mysql:host=192.168.1.254;port=3306;dbname=jdcloud";
	$cnn = new PDO($dsn, "yibo", "Yibo@2019");
	$rv = $cnn->exec("INSERT INTO Ordr (amount, dscr, createTm, status) VALUES (128, 'test-set', '2025-2-21 19:00', 'CR')");
	$id = $cnn->lastInsertId();
	$res->end("[0,$id]");
});

$server->start();

测试时,可以使用apache自带的ab工具,如:ab -c10 -t2 http://127.0.0.1:8081/,-c10是开10个并发,-t2是持续2秒,基本上程序立即就死掉。
用-c1为1个并发,此时可正常运行。

@skyshore2001 skyshore2001 changed the title windows环境下PDO组件并发访问时程序崩溃 cygwin-x64版本PDO组件并发访问时程序崩溃 May 11, 2025
matyhtf added a commit that referenced this issue Jun 2, 2025
…nts in the Poll event handler on the Cygwin platform. Fix GH-5760 GH-5759 GH-5758
@matyhtf matyhtf closed this as completed Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants