Conversation
# Conflicts: # caddy/caddy_test.go
|
Hi @AlliBalliBaba, any news on this side? 🙂 |
|
I experimented a lot with juggling thread states, but not sure it's possible to make a reset fully safe from our side alone. There are 2 main race conditions:
The first race condition kind of gets mitigated by the changes in this PR. THe second one would need to somehow be fixed in php-src or requires a hook to reject opcache_resets. |
|
Can we try doing what we do with the environment functions and simply override/replace the existing one:
|
|
Yeah I tried that as well. But an But maybe overwriting the user function would still be a good first step 👍 |
I tried this and it kind of works, but workers are an issue. Only got it working by locking new requests, draining all workers, doing the reset, restarting all workers and then unlocking. |
|
Oh I just realized that overwriting |
|
Yes, I hard linked because opcache is always active in 8.5+ (which is where I test). I'll tidy up my changes and merge them on top of this branch when I get to it. |
|
Maybe we can make it a requirement also for other PHP versions, not sure how many installations there are without it. |
|
You already had logic to check whether opcache exists in the branch so I only had to pick in a minor change here. Let's see if tests pass. Edit: well, apparently not. I only tested with 8.5 locally and guess what's passing x) Okay, I think I get the issue now. Hard linking to opcache won't help because the init chain for shared extensions is different than for static extensions, which is why it works for me locally, but not in CI in < 8.5. Need to wait with actually calling opcache reset until the extension is properly loaded. |
e54cd96 to
5c8e340
Compare
5c8e340 to
1d75824
Compare
e7bd25a to
0d87765
Compare
|
Alright, we're down to php 8.2 segfaulting. I'm not terribly keep to find out why. |
|
Down to only debian 8.2 failing... |
|
Down to half the debian tests failing x) |
|
At this point I have no idea what it could be, I'm out of ideas. I cannot reproduce the segfault on 8.2 locally. |
|
Maybe we just don't use this when building 8.2? 8.2 is already EOL, just security support at this point, and even that ends soon. |
15aae23 to
22c6ba6
Compare
fc58c35 to
e9533b8
Compare
|
I've wasted too much time on this. I don't have the faintest idea why php 8.2 is failing on this branch. Behaviour should be identical to origin/main. |
ecfb435 to
eced1fd
Compare
1092d25 to
d88821a
Compare
|
@withinboredom's proposal looks the best forward to me. If someone really needs 8.2, he can always provide a patch later 😅 |
|
I've been trying this, right now the branch should have zero behavioural changes compared to main, yet for some reason the 8.2 docker builds are segfaulting. I've guarded every piece of changed logic behind php >= 8.3, but that doesn't make a difference. |
|
So it actually seems completely unrelated to this branches changes... |
|
Ah sry @henderkes, thought you knew from this also happening in #2272. The opcache preload tests were always segfaulting in 8.2. The PR that added the tests (#2257) did not trigger the Docker Images build, so this went under the radar. Still haven't looked into why they are failing. Worst case scenario, we'll remove them again. |
|
You can merge #2284 into this branch for test fixes.
I feel you, chasing race conditions in this branch also took me in a circle. |
I looked at the last 3 runs on the main branch and they were green with the test passing, so I thought it had to be connected to this branch. Extremely annoying, but kind of my own fault for not remembering them. I've removed the 8.2 specific workarounds here so it does the safe session reset for every php version. Only 9 months to go for 8.2 support anyway... |
| func RestartWorkers() { | ||
| // disallow scaling threads while restarting workers | ||
| scalingMu.Lock() | ||
| defer scalingMu.Unlock() | ||
|
|
||
| threadsToRestart := drainWorkerThreads() | ||
|
|
||
| for _, thread := range threadsToRestart { | ||
| thread.drainChan = make(chan struct{}) | ||
| thread.state.Set(state.Ready) | ||
| } | ||
| restartThreadsAndOpcacheReset(false) | ||
| } |
There was a problem hiding this comment.
I wonder if restartWorkers should also restart regular threads, I suspect that might be what's causing #2265
There was a problem hiding this comment.
I also want to try under which conditions opcache_reset is not strictly necessary with restart_workers, something for a different PR.
Signed-off-by: Marc <m@pyc.ac>
|
Final test for this branch would be the moodle installation from #1737 if you get around to try it. Otherwise I can try setting it up again. |
Idea to fix #1737
Just a WIP, to test in CI.