You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using ConnectionPool.lockConnection() in parallel in multiple tasks (single thread), under certain conditions it hangs.
On my CentOS 7 x86_64 + vibe.d 0.7.29 this code
/+ dub.json: { "name": "test", "dependencies": { "vibe-d:core": "0.7.29" } }+/importstd.stdio;
importstd.socket;
importstd.datetime;
importstd.functional;
import vibe.core.core;
import vibe.core.log;
import vibe.core.concurrency;
import vibe.core.connectionpool;
classConn {}
voidmain() {
runTask({
// create pool with 2 max connectionsauto pool = new ConnectionPool!Conn({ returnnew Conn; }, 2);
auto task = Task.getThis(); // main taskvoidworker(int id) {
{
auto conn = pool.lockConnection(); // <-- worker(4) hangs here
sleep(1.msecs); // <-- important, without sleep everything works fine
}
task.send(id); // send signal to the main task
}
// run 4 tasks (2 * pool max connections)
runTask(&worker, 1);
runTask(&worker, 2);
runTask(&worker, 3);
runTask(&worker, 4);
// wait for first signal and run one more task
writefln("recv %s", receiveOnly!int);
runTask(&worker, 5);
// wait for other signals
writefln("recv %s", receiveOnly!int);
writefln("recv %s", receiveOnly!int);
writefln("recv %s", receiveOnly!int);
writefln("recv %s", receiveOnly!int);
exitEventLoop();
});
runEventLoop();
}
outputs
recv 1
recv 2
recv 3
recv 5
and never exits the even loop.
Where is recv 4?
The text was updated successfully, but these errors were encountered:
When using
ConnectionPool.lockConnection()
in parallel in multiple tasks (single thread), under certain conditions it hangs.On my CentOS 7 x86_64 + vibe.d 0.7.29 this code
outputs
and never exits the even loop.
Where is
recv 4
?The text was updated successfully, but these errors were encountered: