Skip to content

Conversation

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

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

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

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

Thank you

Copy link
Contributor

@GrahamCampbell GrahamCampbell left a comment

Choose a reason for hiding this comment

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

Noice.

@shadowhand
Copy link
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
Copy link
Member Author

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
@mnapoli mnapoli deleted the timeouts-fpm-again branch January 31, 2022 15:02
@shadowhand
Copy link
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.

6 participants