- Notifications
You must be signed in to change notification settings - Fork4.9k
Commita734fd5
committed
autovacuum: Drop orphan temp tables more quickly but with more caution.
Previously, we only dropped an orphan temp table when it became oldenough to threaten wraparound; instead, doing it immediately. Theonly value of waiting is that someone might be able to examine thecontents of the orphan temp table for forensic purposes, but it'spretty difficult to actually do that and few users will wish to do so.On the flip side, not performing the drop immediately generates logspam and bloats pg_class.In addition, per a report from Grigory Smolkin, if a temporary schemacontains a very large number of temporary tables, a backend attemptingto clear the temporary schema might fail due to lock table exhaustion.It's helpful for autovacuum to clean up after such cases, and we don'twant it to wait for wraparound to threaten before doing so. Toprevent autovacuum from failing in the same manner as a backend tryingto drop an entire temp schema, remove orphan temp tables in batches of50, committing after each batch, so that we don't accumulate anunbounded number of locks. If a drop fails, retry other orphan tablesthat need to be dropped up to 10 times before giving up. With thissystem, if a backend does fail to clean a temporary schema due tolock table exhaustion, autovacuum should hopefully put things rightthe next time it processes the database.Discussion: CAB7nPqSbYT6dRwsXVgiKmBdL_ARemfDZMPA+RPeC_ge0GK70hA@mail.gmail.comMichael Paquier, with a bunch of comment changes by me.1 parentf24cf96 commita734fd5
1 file changed
+127
-26
lines changedLines changed: 127 additions & 26 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
130 | 130 |
| |
131 | 131 |
| |
132 | 132 |
| |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
133 | 144 |
| |
134 | 145 |
| |
135 | 146 |
| |
| |||
1887 | 1898 |
| |
1888 | 1899 |
| |
1889 | 1900 |
| |
| 1901 | + | |
| 1902 | + | |
1890 | 1903 |
| |
1891 | 1904 |
| |
1892 | 1905 |
| |
| |||
1895 | 1908 |
| |
1896 | 1909 |
| |
1897 | 1910 |
| |
| 1911 | + | |
1898 | 1912 |
| |
1899 | 1913 |
| |
1900 | 1914 |
| |
| |||
2038 | 2052 |
| |
2039 | 2053 |
| |
2040 | 2054 |
| |
2041 |
| - | |
2042 |
| - | |
2043 |
| - | |
2044 |
| - | |
| 2055 | + | |
| 2056 | + | |
| 2057 | + | |
2045 | 2058 |
| |
2046 |
| - | |
2047 |
| - | |
2048 |
| - | |
2049 |
| - | |
2050 |
| - | |
2051 |
| - | |
2052 |
| - | |
2053 |
| - | |
2054 |
| - | |
2055 |
| - | |
2056 |
| - | |
2057 |
| - | |
2058 |
| - | |
2059 |
| - | |
2060 |
| - | |
2061 |
| - | |
2062 |
| - | |
2063 |
| - | |
2064 |
| - | |
2065 |
| - | |
2066 |
| - | |
2067 |
| - | |
| 2059 | + | |
2068 | 2060 |
| |
2069 | 2061 |
| |
2070 | 2062 |
| |
| |||
2161 | 2153 |
| |
2162 | 2154 |
| |
2163 | 2155 |
| |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
| 2202 | + | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
| 2216 | + | |
| 2217 | + | |
| 2218 | + | |
| 2219 | + | |
| 2220 | + | |
| 2221 | + | |
| 2222 | + | |
| 2223 | + | |
| 2224 | + | |
| 2225 | + | |
| 2226 | + | |
| 2227 | + | |
| 2228 | + | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
| 2249 | + | |
| 2250 | + | |
| 2251 | + | |
| 2252 | + | |
| 2253 | + | |
| 2254 | + | |
| 2255 | + | |
| 2256 | + | |
| 2257 | + | |
| 2258 | + | |
| 2259 | + | |
| 2260 | + | |
| 2261 | + | |
| 2262 | + | |
| 2263 | + | |
| 2264 | + | |
2164 | 2265 |
| |
2165 | 2266 |
| |
2166 | 2267 |
| |
|
0 commit comments
Comments
(0)