- Notifications
You must be signed in to change notification settings - Fork5
Commitda8a716
committed
Fix latent(?) race condition in LockReleaseAll.
We have for a long time checked the head pointer of each of the backend'sproclock lists and skipped acquiring the corresponding locktable partitionlock if the head pointer was NULL. This was safe enough in the days whenproclock lists were changed only by the owning backend, but it is prettyquestionable now that the fast-path patch added cases where backends addentries to other backends' proclock lists. However, we don't really wishto revert to locking each partition lock every time, because in simpletransactions that would add a lot of useless lock/unlock cycles onalready-heavily-contended LWLocks. Fortunately, the only way that anotherbackend could be modifying our proclock list at this point would be if itwas promoting a formerly fast-path lock of ours; and any such lock must beone that we'd decided not to delete in the previous loop over the locallocktable. So it's okay if we miss seeing it in this loop; we'd just decidenot to delete it again. However, once we've detected a non-empty list,we'd better re-fetch the list head pointer after acquiring the partitionlock. This guards against possibly fetching a corrupt-but-non-null pointerif pointer fetch/store isn't atomic. It's not clear if any practicalarchitectures are like that, but we've never assumed that before and don'twish to start here. In any case, the situation certainly deserves a codecomment.While at it, refactor the partition traversal loop to use a for() constructinstead of a while() loop with goto's.Back-patch, just in case the risk is real and not hypothetical.1 parentd51a8c5 commitda8a716
1 file changed
+46
-24
lines changedLines changed: 46 additions & 24 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2098 | 2098 |
| |
2099 | 2099 |
| |
2100 | 2100 |
| |
| 2101 | + | |
2101 | 2102 |
| |
2102 |
| - | |
2103 |
| - | |
2104 |
| - | |
2105 |
| - | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
2106 | 2124 |
| |
2107 | 2125 |
| |
2108 | 2126 |
| |
2109 | 2127 |
| |
2110 |
| - | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
2111 | 2132 |
| |
2112 | 2133 |
| |
2113 |
| - | |
2114 | 2134 |
| |
2115 | 2135 |
| |
2116 | 2136 |
| |
| |||
2123 | 2143 |
| |
2124 | 2144 |
| |
2125 | 2145 |
| |
2126 |
| - | |
| 2146 | + | |
2127 | 2147 |
| |
2128 | 2148 |
| |
2129 | 2149 |
| |
| |||
2139 | 2159 |
| |
2140 | 2160 |
| |
2141 | 2161 |
| |
2142 |
| - | |
| 2162 | + | |
2143 | 2163 |
| |
2144 | 2164 |
| |
2145 | 2165 |
| |
| |||
2168 | 2188 |
| |
2169 | 2189 |
| |
2170 | 2190 |
| |
2171 |
| - | |
2172 |
| - | |
2173 |
| - | |
2174 | 2191 |
| |
2175 | 2192 |
| |
2176 | 2193 |
| |
| |||
3142 | 3159 |
| |
3143 | 3160 |
| |
3144 | 3161 |
| |
| 3162 | + | |
3145 | 3163 |
| |
3146 |
| - | |
3147 |
| - | |
3148 |
| - | |
3149 |
| - | |
| 3164 | + | |
| 3165 | + | |
| 3166 | + | |
| 3167 | + | |
| 3168 | + | |
| 3169 | + | |
| 3170 | + | |
| 3171 | + | |
| 3172 | + | |
| 3173 | + | |
3150 | 3174 |
| |
3151 | 3175 |
| |
3152 | 3176 |
| |
3153 | 3177 |
| |
3154 |
| - | |
| 3178 | + | |
| 3179 | + | |
| 3180 | + | |
| 3181 | + | |
3155 | 3182 |
| |
3156 |
| - | |
3157 |
| - | |
3158 | 3183 |
| |
3159 | 3184 |
| |
3160 | 3185 |
| |
| |||
3166 | 3191 |
| |
3167 | 3192 |
| |
3168 | 3193 |
| |
3169 |
| - | |
| 3194 | + | |
3170 | 3195 |
| |
3171 | 3196 |
| |
3172 | 3197 |
| |
| |||
3177 | 3202 |
| |
3178 | 3203 |
| |
3179 | 3204 |
| |
3180 |
| - | |
| 3205 | + | |
3181 | 3206 |
| |
3182 | 3207 |
| |
3183 | 3208 |
| |
| |||
3219 | 3244 |
| |
3220 | 3245 |
| |
3221 | 3246 |
| |
3222 |
| - | |
3223 |
| - | |
3224 |
| - | |
3225 | 3247 |
| |
3226 | 3248 |
| |
3227 | 3249 |
| |
| |||
3918 | 3940 |
| |
3919 | 3941 |
| |
3920 | 3942 |
| |
3921 |
| - | |
| 3943 | + | |
3922 | 3944 |
| |
3923 | 3945 |
| |
3924 | 3946 |
| |
|
0 commit comments
Comments
(0)