You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: add rwlock for implicit opcache restarts (OOM/hash overflow)
PR #2073 drains all threads for explicit opcache_reset() calls, but
WordPress triggers implicit restarts via opcache_invalidate() filling
opcache memory → zend_accel_schedule_restart() → restart_pending → the
actual reset runs during the next php_request_startup(). That path
bypasses the opcache_reset() override and races on shared memory.
Add a pthread_rwlock around the request lifecycle:
- Normal requests: read lock (concurrent, single atomic CAS)
- When zend_accel_schedule_restart_hook fires: set an atomic flag
- Next php_request_startup(): sees flag → write lock (exclusive),
blocks until all current requests complete, resets safely
- After startup: unlock, all threads resume
Combined with PR #2073, this covers both explicit opcache_reset()
(thread drain) and implicit OOM/hash-overflow restarts (rwlock).
Testing: without this patch, crashes every ~10 min on a WordPress
multisite. With PR #2073 alone, same crash frequency. With the rwlock
from our PR #2349 alone, crashes reduced to every 6-12 hours (worker
threads not covered). Combined fix expected to eliminate both paths.
0 commit comments