Skip to content

Restart FPM completely in case of timeouts#1144

Merged
mnapoli merged 1 commit into
masterfrom
timeouts-fpm-again
Jan 31, 2022
Merged

Restart FPM completely in case of timeouts#1144
mnapoli merged 1 commit into
masterfrom
timeouts-fpm-again

Conversation

@mnapoli

@mnapoli mnapoli commented Jan 27, 2022

Copy link
Copy Markdown
Member

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
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
Copy Markdown
Member Author

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

mnapoli commented Jan 27, 2022

Copy link
Copy Markdown
Member Author

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

@shadowhand shadowhand left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@BenCoffeed

Copy link
Copy Markdown

Thank you

@GrahamCampbell GrahamCampbell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Noice.

@shadowhand

Copy link
Copy Markdown
Contributor

@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

mnapoli commented Jan 31, 2022

Copy link
Copy Markdown
Member Author

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

@mnapoli mnapoli merged commit 219aea6 into master Jan 31, 2022
@mnapoli mnapoli deleted the timeouts-fpm-again branch January 31, 2022 15:02
@shadowhand

Copy link
Copy Markdown
Contributor

@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.

5 participants