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
fpm TCP connection stay CLOSE_WAIT when restart mongodb server. #597
Comments
any one reply me |
Apologies for losing track of this.
When you say "get wrong return", are you referring to the PHP driver throwing an exception? If a PHP request uses a previously persisted socket, which is now in the This is documented behavior from our server selection and server discovery and monitoring specifications. There are a few connection options options that you may be able to use to avoid this error:
Combining This begs the question: what can we do to mitigate the edge case where we don't discover a dropped connection until attempting an operation on it? One future improvement to the SDAM spec is to retry failed |
Indeed, TCP connection for the CLOSE_WAITE state, PHP dirver should throw Exception, I actually use the process is to capture the Exception. In the extreme case, when the TCP connection is not available, I certainly want to make one attempt to reestablish a connection before returning a "Stream is closed" error as you described in CDRIVER-2172. But now, but how should I solve this problem now? I use google translate, thanks reading. |
In addition, ask what is SDAM? Googlt tells me I use google translate, thanks reading. |
I would start with Beyond that, CDRIVER-2075 and CDRIVER-2172 should allow the driver to retry failed monitoring attempts one time without having to wait for
This is an acronym for server discovery and monitoring, which is one of the two specs I referenced in my last comment. |
Before executing the real Mongo operation, I will execute the following code twice before returning to success.
At the same time I also set the parameters below
But follow-up mongo operation will still return the database connection error after the success of the implementation of |
In my last comment, I wrote:
You are using It's not entirely clear to me from your previous comment which errors you were getting, but it sounds like you experienced two exceptions on the same socket. I created a script to test that and discovered what I believe to be a separate bug in libmongoc (CDRIVER-2174). Please read through that issue and experiment with the included test script (modified for your local server, of course) and confirm if that is the same error you're experiencing. |
In fact,
This code in my logic is going to checke the connection state of database( with one more check request when checking failed), to ensure that the follow-up database operation success. So come back to the question I want to express in this issue: For now, the The problem of this database connection to my software had a big bad impact, but also would like to ask if there are some mitigation measures. I use Google translate, The syntax is not smooth, thanks reading. |
If I understand correctly, you are still only retrying the operation once after the first "Stream is closed" exception. In CDRIVER-2174, I demonstrated that the second retry after "Stream is closed" may result in a second exception: "Failed to send "ismaster" command with database "admin": Failure during socket delivery: Broken pipe (32)". Therefore, two retries are necessary for the driver to recover and leave the socket in a usable state. Did you attempt to reproduce my report in CDRIVER-2174? I'd like to confirm that you understand what I've reported in that issue and the code paths being exercised by the test script I've attached to the issue, as I believe it accurately reflects your issue.
I might suggest restarting FPM after you restart the MongoDB server, which would effectively flush any persisted connections. Apart from that, I believe we've covered all other mitigation measures by discussing the aforementioned connection string options. In conflusion, there are a number of outstanding issues with libmongoc that must be fixed before the PHP driver can avoid the edge case you're experiencing. |
I try the there is no problem, thank you very much。 |
stop or restart mongo server, the fpm connection go into CLOSE_WAIT, but not disconnect.
my problem
It's a connection BUG? Or I used in a wrong way? Or my start&stop scripts has some problem?
Environment
my PHP was make from source code, not installed through a third-party bundle
some php info
mongo stop & start script
start
/bin/mongod -f ./conf/mongodb.yaml
stop
./bin/mongod -f ./conf/mongodb.yaml --shutdown
./conf/mongodb.yaml
when restart mongo server the fpm tcp connection was close_waite
the mongo server stop and start, but the fpm connection stayed in
CLOSE_WAIT
, my application goes wrong when connect to the mongo serverbut when the fpm connection pool reconnect, one of the connection get wrong return and change into
ESTABLISHED
my problem repeat
It's a connection BUG? Or I used in a wrong way? Or my start&stop scripts has some problem?
My English was not very well, thanks reading
The text was updated successfully, but these errors were encountered: