forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit3b8981b
committed
Fix race in Parallel Hash Join batch cleanup.
With very unlucky timing and parallel_leader_participation off, PHJcould attempt to access per-batch state just as it was being freed.There was code intended to prevent that by checking for a clearedpointer, but it was buggy.Fix, by introducing an extra barrier phase. The new phasePHJ_BUILD_RUNNING means that it's safe to access the per-batch state tofind a batch to help with, and PHJ_BUILD_DONE means that it is too late.The last to detach will free the array of per-batch state as before, butnow it will also atomically advance the phase at the same time, so thatlate attachers can avoid the hazard, without the data race. Thismirrors the way per-batch hash tables are freed (see phasesPHJ_BATCH_PROBING and PHJ_BATCH_DONE).Revealed by a one-off build farm failure, where BarrierAttach() failed asanity check assertion, because the memory had been clobbered bydsa_free().Back-patch to 11, where the code arrived.Reported-by: Michael Paquier <michael@paquier.xyz>Discussion:https://postgr.es/m/20200929061142.GA29096%40paquier.xyz1 parent3792959 commit3b8981b
File tree
3 files changed
+58
-32
lines changed- src
- backend/executor
- include/executor
3 files changed
+58
-32
lines changedLines changed: 32 additions & 15 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
333 | 333 |
| |
334 | 334 |
| |
335 | 335 |
| |
336 |
| - | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
337 | 343 |
| |
338 | 344 |
| |
339 | 345 |
| |
340 |
| - | |
| 346 | + | |
341 | 347 |
| |
342 | 348 |
| |
343 | 349 |
| |
| 350 | + | |
344 | 351 |
| |
345 | 352 |
| |
346 | 353 |
| |
| |||
624 | 631 |
| |
625 | 632 |
| |
626 | 633 |
| |
627 |
| - | |
| 634 | + | |
628 | 635 |
| |
629 | 636 |
| |
630 | 637 |
| |
| |||
3048 | 3055 |
| |
3049 | 3056 |
| |
3050 | 3057 |
| |
3051 |
| - | |
3052 |
| - | |
3053 |
| - | |
3054 |
| - | |
3055 |
| - | |
| 3058 | + | |
| 3059 | + | |
| 3060 | + | |
3056 | 3061 |
| |
3057 |
| - | |
3058 |
| - | |
| 3062 | + | |
3059 | 3063 |
| |
3060 | 3064 |
| |
3061 | 3065 |
| |
| |||
3175 | 3179 |
| |
3176 | 3180 |
| |
3177 | 3181 |
| |
3178 |
| - | |
| 3182 | + | |
| 3183 | + | |
| 3184 | + | |
| 3185 | + | |
| 3186 | + | |
| 3187 | + | |
| 3188 | + | |
| 3189 | + | |
| 3190 | + | |
| 3191 | + | |
3179 | 3192 |
| |
3180 |
| - | |
3181 | 3193 |
| |
3182 | 3194 |
| |
3183 | 3195 |
| |
| |||
3193 | 3205 |
| |
3194 | 3206 |
| |
3195 | 3207 |
| |
3196 |
| - | |
| 3208 | + | |
3197 | 3209 |
| |
| 3210 | + | |
| 3211 | + | |
| 3212 | + | |
| 3213 | + | |
| 3214 | + | |
| 3215 | + | |
3198 | 3216 |
| |
3199 | 3217 |
| |
3200 | 3218 |
| |
3201 | 3219 |
| |
3202 | 3220 |
| |
3203 | 3221 |
| |
3204 |
| - | |
3205 |
| - | |
3206 | 3222 |
| |
| 3223 | + | |
3207 | 3224 |
| |
3208 | 3225 |
| |
3209 | 3226 |
| |
|
Lines changed: 24 additions & 16 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
45 | 45 |
| |
46 | 46 |
| |
47 | 47 |
| |
48 |
| - | |
| 48 | + | |
| 49 | + | |
49 | 50 |
| |
50 | 51 |
| |
51 | 52 |
| |
| |||
73 | 74 |
| |
74 | 75 |
| |
75 | 76 |
| |
76 |
| - | |
| 77 | + | |
77 | 78 |
| |
78 | 79 |
| |
79 | 80 |
| |
| |||
95 | 96 |
| |
96 | 97 |
| |
97 | 98 |
| |
98 |
| - | |
99 |
| - | |
100 |
| - | |
101 |
| - | |
102 |
| - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
103 | 109 |
| |
104 | 110 |
| |
105 | 111 |
| |
| |||
317 | 323 |
| |
318 | 324 |
| |
319 | 325 |
| |
| 326 | + | |
320 | 327 |
| |
321 | 328 |
| |
322 | 329 |
| |
| |||
329 | 336 |
| |
330 | 337 |
| |
331 | 338 |
| |
332 |
| - | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
333 | 348 |
| |
334 | 349 |
| |
| 350 | + | |
335 | 351 |
| |
336 | 352 |
| |
337 | 353 |
| |
| |||
1090 | 1106 |
| |
1091 | 1107 |
| |
1092 | 1108 |
| |
1093 |
| - | |
1094 |
| - | |
1095 |
| - | |
1096 |
| - | |
1097 |
| - | |
1098 |
| - | |
1099 |
| - | |
1100 |
| - | |
1101 | 1109 |
| |
1102 | 1110 |
| |
1103 | 1111 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
258 | 258 |
| |
259 | 259 |
| |
260 | 260 |
| |
261 |
| - | |
| 261 | + | |
| 262 | + | |
262 | 263 |
| |
263 | 264 |
| |
264 | 265 |
| |
|
0 commit comments
Comments
(0)