-
-
Notifications
You must be signed in to change notification settings - Fork 250
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
FrankenPHP serving stale requests #881
Comments
I'm pretty sure FrankenPHP isn't keeping old requests in memory anymore (we fixed that memory leak awhile ago), but even then it wasn't returning them to the wrong connection, just keeping them around in memory. The only thing I can think of is threading shenanigans between PHP & go, or a bug in symfony (the more likely option, TBH), which could be an issue in either one (no idea without a way of reproducing it). It'd be great if you could figure out which of these is true:
|
TBH, the most likely issue is the request/response is being stored in the container and not regenerated for every request. This would mean that if something were to take the request/response from the container, it would be a mismash between all the other requests/responses that did so. |
This can (and likely is) also be an application bug. Like a global state that isn't reset between requests. EasyAdmin was suffering of a bug like this for instance. |
Closing for now as there is nothing we can do without more information. See this EasyAdmin path, which fixes a (likely) similar issue. If you think that it's not an issue in your app, feel free to reopen. |
I can confirm this issue for a very simple setup here.
The assumption for me was that the reset interface should be enough to reset the context state. For good measure I also tagged the service with I then completely eliminated the local variable and cache, always fetching the data from API. And still, some responses contain the old content, some the new. API responses are never cached, I also confirmed by completely flushing Redis that there's no way stale data could be fetched (even though caching was disabled completely). EDIT: Oh, and everything, caching and local variable, works perfectly fine if I disable worker mode. |
This is probably a bug in the Symfony Cache. If you have a simple reproducer, could you publish it? I'll take a look. |
This is likely due to the workers. ie, you have eight workers and they deliver responses in round-robin order, so you end up with one "corrupted" worker. If you are up for digging deeper, search for accesses to |
I completely eliminated everything Symfony related, except for a REST API call (not even some obscure Doctrine caching was possible).
That's exactly what I thought and the reason I wanted to mention it.
There's not a single static variable anywhere. I was able to reproduce the problem even after changing the code to do an API call with every access to the getter (instead of saving the context locally). The object returned is an instance created from JSON, no static variables, etc. It's a shared Symfony service, but completely stateless. I'll try to come up with a reproducer as soon as possible. |
Would you be able to share your project? A reproducer will help a lot to find the underlying issue. This is interesting that it occurs after 500 errors. The Symfony error handling system is quite complex. Maybe some states aren't properly reset when it is triggered? |
Unfortunately I can't share that project. I'll try to write a reproducer in a pulic repo based on symfony/docker though. This way either I'll find whats wrong with my project and report back, or I'll have a reproducer ready that hopefull helps to narrow down the problem. |
Guys, I'm so sorry for the noise. After a lot of debugging and trying to reproduce the problem in various environments and containers I was finally able to reliably reproduce it locally (8 cores / 16 threads complicate things a lot if you don't read the FrankenPHP docs or even log messages). Days and hours of debugging later I finally found the culprit in an external library that was using a local variable (and for some weird reason/oversight/typo a service wasn't overridden and should have been). Sorry again for not being more thorough. TL;DR for anyone finding this issue in the future: If some of the requests predictably return outdated data (e.g., every n-th request), somewhere a local variable is most likely the culprit. |
Thanks for the feedback! |
What happened?
Sometimes franken php is serving stale requests with Symfony. It returns random previous requests no matter what they contain (errors included). I'm not sure when this happens but it seems to me that it happens after multiple 5xx responses (but not everytime). Only thing that helps is restarting the docker container. I don't think it's Symfony issue because it was working just fine on fastcgi but it's true I migrated the project to Symfony 7 around the same time. I understand that this description isn't much you can work with but I hope I'm not the only one its happens to and that someone will have more insight/understanding why is this happening.
This happens no matter the symfony environment is running.
This is my Caddyfile
I'm starting my caddy server with
frankenphp run --config /etc/caddy/Caddyfile --adapter caddyfile
The app is Symfony 7 with API Platform, nothing else is special about it.
Build Type
Docker (Debian Bookworm)
Worker Mode
Yes
Operating System
macOS
CPU Architecture
Apple Silicon
PHP configuration
Really long text :)
Relevant log output
No response
The text was updated successfully, but these errors were encountered: