Commit 4ebe8ad
committed
fix: add rwlock for implicit opcache restarts (OOM/hash overflow)
PR php#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 php#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 php#2073 alone, same crash frequency. With the rwlock
from our PR php#2349 alone, crashes reduced to every 6-12 hours (worker
threads not covered). Combined fix expected to eliminate both paths.1 parent d5ed5da commit 4ebe8ad
1 file changed
Lines changed: 50 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
86 | 114 | | |
87 | 115 | | |
88 | 116 | | |
| |||
1111 | 1139 | | |
1112 | 1140 | | |
1113 | 1141 | | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
1114 | 1154 | | |
| 1155 | + | |
1115 | 1156 | | |
1116 | 1157 | | |
1117 | 1158 | | |
| |||
1143 | 1184 | | |
1144 | 1185 | | |
1145 | 1186 | | |
| 1187 | + | |
1146 | 1188 | | |
1147 | 1189 | | |
1148 | 1190 | | |
| |||
1158 | 1200 | | |
1159 | 1201 | | |
1160 | 1202 | | |
| 1203 | + | |
1161 | 1204 | | |
1162 | 1205 | | |
1163 | 1206 | | |
| |||
1277 | 1320 | | |
1278 | 1321 | | |
1279 | 1322 | | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
1280 | 1330 | | |
1281 | 1331 | | |
1282 | 1332 | | |
| |||
0 commit comments