Skip to content

FPM: fastcgi_finish_request supports force close connection param #10273

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Appla
Copy link
Contributor

@Appla Appla commented Jan 10, 2023

when using fastcgi keepalive connection and fastcgi_finish_request, potentially deadlock may happens.

for example: process-a request same host after called fastcgi_finish_request, the proxy may using keepalived connection which is serve by same process(process-a), this may causes a dead lock

this PR introduced a new param which let user decide whether to close a [keepalive] connection.

@cmb69
Copy link
Member

cmb69 commented Jan 10, 2023

Thanks for the PR!

Instead of manually modifying fpm_main_arginfo.h, you should modify fpm_main.stub.php instead, and then use build/gen_stub.php to regenerate fpm_main_arginfo.h.

@Appla
Copy link
Contributor Author

Appla commented Jan 11, 2023

Thanks for the PR!

Instead of manually modifying fpm_main_arginfo.h, you should modify fpm_main.stub.php instead, and then use build/gen_stub.php to regenerate fpm_main_arginfo.h.

Thanks, I will update later

@Appla
Copy link
Contributor Author

Appla commented Jan 13, 2023

Looks like LINUX_X64_DEBUG_NTS fails due to

DBA CDB handler test [ext/dba/tests/dba_cdb_001.phpt] (info: CDB does not support replace or delete)

any suggestion?

@bukka
Copy link
Member

bukka commented Jan 13, 2023

It would be also good if you could create an issue for the actual problem describing in more details how to reproduce the deadlock to see if there might be some other solutions for this as well.

This is probably still useful in any case but I think there should be also some way for administrator to disallow closing of the connection as it might have negative impact on the server performance. That way could be some fpm conf option that would for example allow to disable ability to close the connection.

This should also have a test. It could be done by sending 2 requests in tester and adding some extra check to the client and tester itself. I would need to try it but think it should be doable.

@Appla
Copy link
Contributor Author

Appla commented Jan 16, 2023

It would be also good if you could create an issue for the actual problem describing in more details how to reproduce the deadlock to see if there might be some other solutions for this as well.
Thanks!

Issue added @ #10335

This is probably still useful in any case but I think there should be also some way for administrator to disallow closing of the connection as it might have negative impact on the server performance. That way could be some fpm conf option that would for example allow to disable ability to close the connection.

Good point, but I think as many exists functions that maybe misused, this usally prevent by CODE checker in my experience. If we do need a new option, I would change this PR later.

This should also have a test. It could be done by sending 2 requests in tester and adding some extra check to the client and tester itself. I would need to try it but think it should be doable.

I am not familiar with this but I would try when I get free.

@Appla
Copy link
Contributor Author

Appla commented Feb 15, 2023

I just tried writing a PHP for this MR, but it seems not possible without a standalone proxy like nginx to do this for me.

the core part is that the PROXY will reuse the process bound connection based on the protocol perspective which the process will not handle connection under normal circumstances.

any suggestion?

@bukka
Copy link
Member

bukka commented Feb 17, 2023

The fcgi test client has keep a live support so it should be possible. I might take a look next months if it doesn't work for you.

@Appla
Copy link
Contributor Author

Appla commented Feb 17, 2023

The fcgi test client has keep a live support so it should be possible. I might take a look next months if it doesn't work for you.

I tried it, but I don't know how to simulate the situation I described above using the keep-alive functionality of the client based on the pfsockopen implementation.
looking forward to your try
Thanks.

@bukka
Copy link
Member

bukka commented Mar 4, 2023

I just went through my priorities and there are bunch of bugs that I need to look at first so this might take few months at least.

@Appla Appla requested a review from bukka as a code owner October 7, 2023 13:51
@Appla
Copy link
Contributor Author

Appla commented Apr 11, 2024

I just went through my priorities and there are bunch of bugs that I need to look at first so this might take few months at least.

Any updates about this?

@bukka
Copy link
Member

bukka commented Apr 12, 2024

This is actually next on my FPM priorities (this and another keep alive things). I'm just starting to look #10335 and will see if there's anything else we could do about this issue. It might take me a bit of time as my time is currently a bit limited and split between some other things.

@Appla Appla requested a review from kocsismate as a code owner April 15, 2024 15:43
@Appla Appla force-pushed the fpm_finish_req_with_conn_control branch from 59d1035 to a5ba93e Compare May 10, 2024 14:10
… control the default behavior of `fastcgi_finish_request` closing keep-alive connections
@kkmuffme
Copy link

I think the new param should be removed again and this should be the default behavior, as currently this behavior has security implications, because it causes #18275

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

Successfully merging this pull request may close these issues.

4 participants