Skip to content

Conversation

@jobs-git
Copy link

@jobs-git jobs-git commented Dec 16, 2018

SplQueue is operated using enqueue() and dequeue() not with push() and pop() which is for Stack.

SplQueue is a FIFO, but use of push/pop turns it into Stack which is LIFO, this has caused numerous disconnections that resulted into a swoole server crash.

By fixing this, disconnection from database server does not cause server crash anymore.

Ref.

SplQueue dequeue
SplQueue enqueue

`SplQueue` is operated using `enqueue()` and `dequeue()` not with `push()` and `pop()` which is for `Stack`.

`SplQueue is a FIFO`, but use of push/pop turns it into Stack which is LIFO, this has caused numerous disconnections that resulted into a swoole server crash.

By fixing this, disconnection from database server does not cause server crash anymore.

Ref.

SplQueue dequeue -> http://php.net/manual/en/splqueue.dequeue.php
SplQueue enqueue -> http://php.net/manual/en/splqueue.enqueue.php
@jobs-git
Copy link
Author

jobs-git commented Dec 17, 2018

Code in here should be updated as well https://github.com/TechEmpower/FrameworkBenchmarks/blob/master/frameworks/PHP/swoole/swoole-server.php

However, it seems that the benchmark did not capture this since it was not testing concurrency thoroughly.

Indribell added a commit to Indribell/FrameworkBenchmarks that referenced this pull request Dec 17, 2018
`SplQueue` is operated using `enqueue()` and `dequeue()` not with `push()` and `pop()` which is for `Stack`.

`SplQueue` is a `FIFO`, but use of `push/pop` turns it into `Stack` which is `LIFO`, this has caused numerous disconnections that resulted into a swoole server crash.

By fixing this, disconnection from database server does not cause server crash anymore.

Ref.

[SplQueue dequeue](http://php.net/manual/en/splqueue.dequeue.php)
[SplQueue enqueue](http://php.net/manual/en/splqueue.enqueue.php)
`SplQueue` is operated using `enqueue()` and `dequeue()` not with `push()` and `pop()` which is for `Stack`.

`SplQueue` is a `FIFO`, but use of `push/pop` turns it into `Stack` which is `LIFO`, this has caused numerous disconnections that resulted into a swoole server crash.

By fixing this, disconnection from database server does not cause server crash anymore.

Ref.

[SplQueue dequeue](http://php.net/manual/en/splqueue.dequeue.php)
[SplQueue enqueue](http://php.net/manual/en/splqueue.enqueue.php)
NateBrady23 pushed a commit to TechEmpower/FrameworkBenchmarks that referenced this pull request Dec 17, 2018
* Updated Swoole version from 2.1.3 to 4.2.9

* Changed push/pop to enqueue/dequeue

See issue #2214 from Swoole reporting:

swoole/swoole-src#2214
@matyhtf matyhtf merged commit 2604e33 into swoole:master Dec 18, 2018
@ghost
Copy link

ghost commented Dec 18, 2018

Great @jobs-git 👍

@twose
Copy link
Member

twose commented Dec 19, 2018

enqueue && dequeue is as same as push && shift, but this is not the reason for the disconnection, don't mislead others.
Using pop is indeed a mistake, but any program cannot depend on the order, every time you take a connection from the connection pool, you must check the status of the connection, even try to reconnect after the request fails. The real network is random and uncertain, the connection will be disconnected at any time, even halfway through your request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants