Skip to content
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

Restart FPM completely in case of timeouts #1144

Merged
merged 1 commit into from Jan 31, 2022
Merged

Restart FPM completely in case of timeouts #1144

merged 1 commit into from Jan 31, 2022

Conversation

Copy link
Member

@mnapoli mnapoli commented Jan 27, 2022

Follow-up of #1133

This is because sending SIGUSR2 to FPM (the previously implemented solution) did not really stop with 100% certainty the PHP script that timed out.

Indeed, it merely interrupted the currently blocked call (e.g. a sleep, a DB call, etc.), flushed the logs and carried on. My guess is that this could have caused the PHP script to continue to run in some cases, possibly running into yet another timeout on a next line (e.g. another DB call).

This PR fixes the timeout test that wasn't really working (🤦) and restarts FPM completely in case of timeout. That is confirmed to completely stop the execution of the timed out script + flush the logs to stderr.

Follow-up of #1133

This is because sending SIGUSR2 to FPM (the previously implemented solution) did not really stop with 100% certainty the PHP script that timed out.

Indeed, it merely interrupted the currently blocked call (e.g. a sleep, a DB call, etc.), flushed the logs and carried on. My guess is that this could have caused the PHP script to continue to run in some cases, possibly running into yet another timeout on a next line (e.g. another DB call).

This PR fixes the timeout test that wasn't really working (🤦) and restarts FPM completely in case of timeout. That is confirmed to completely stop the execution of the timed out script + flush the logs to stderr.
@mnapoli mnapoli added the bug label Jan 27, 2022
@@ -18,6 +18,3 @@ catch_workers_output = yes
; Limit the number of core dump logs to 1 to avoid filling up the /tmp disk
; See https://github.com/brefphp/bref/issues/275
rlimit_core = 1

; Very short timeout to be able to test timeouts without having a very long test suite
request_terminate_timeout = 1
Copy link
Member Author

@mnapoli mnapoli Jan 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a leftover from 2019 that "faked" the results of the timeout test 🤦

@mnapoli
Copy link
Author

@mnapoli mnapoli commented Jan 27, 2022

This is what CloudWatch logs look like now when you have 1 good request followed by 1 timed-out request:

Screen 2022-01-27 16-44

Copy link
Contributor

@shadowhand shadowhand left a comment

Excellent! And good sleuthing to find that it attempts to resume after interrupt!

@BenCoffeed
Copy link

@BenCoffeed BenCoffeed commented Jan 27, 2022

Thank you

Copy link
Contributor

@GrahamCampbell GrahamCampbell left a comment

Noice.

@shadowhand
Copy link

@shadowhand shadowhand commented Jan 28, 2022

@mnapoli can we get a release with this? We're currently trying to upgrade to serverless v3 but stuck because this hasn't been released.

@mnapoli
Copy link
Author

@mnapoli mnapoli commented Jan 31, 2022

@shadowhand you will have to wait until I do, maybe today.

@mnapoli mnapoli merged commit 219aea6 into master Jan 31, 2022
7 checks passed
@mnapoli mnapoli deleted the timeouts-fpm-again branch Jan 31, 2022
@shadowhand
Copy link

@shadowhand shadowhand commented Jan 31, 2022

@mnapoli thank you! 💛

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

Successfully merging this pull request may close these issues.

None yet

5 participants