forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit46d9bfb
committed
Fix race between DROP TABLESPACE and checkpointing.
Commands like ALTER TABLE SET TABLESPACE may leave files for the nextcheckpoint to clean up. If such files are not removed by the time DROPTABLESPACE is called, we request a checkpoint so that they are deleted.However, there is presently a window before checkpoint start where newunlink requests won't be scheduled until the following checkpoint. Thismeans that the checkpoint forced by DROP TABLESPACE might not remove thefiles we expect it to remove, and the following ERROR will be emitted:ERROR: tablespace "mytblspc" is not emptyTo fix, add a call to AbsorbSyncRequests() just before advancing theunlink cycle counter. This ensures that any unlink requests forwardedprior to checkpoint start (i.e., when ckpt_started is incremented) willbe processed by the current checkpoint. Since AbsorbSyncRequests()performs memory allocations, it cannot be called within a criticalsection, so we also need to move SyncPreCheckpoint() to beforeCreateCheckPoint()'s critical section.This is an old bug, so back-patch to all supported versions.Author: Nathan Bossart <nathandbossart@gmail.com>Reported-by: Nathan Bossart <nathandbossart@gmail.com>Reviewed-by: Thomas Munro <thomas.munro@gmail.com>Reviewed-by: Andres Freund <andres@anarazel.de>Discussion:https://postgr.es/m/20220215235845.GA2665318%40nathanxps131 parent4477dcb commit46d9bfb
2 files changed
+21
-8
lines changedLines changed: 8 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6297 | 6297 |
| |
6298 | 6298 |
| |
6299 | 6299 |
| |
| 6300 | + | |
| 6301 | + | |
| 6302 | + | |
| 6303 | + | |
| 6304 | + | |
| 6305 | + | |
| 6306 | + | |
| 6307 | + | |
6300 | 6308 |
| |
6301 | 6309 |
| |
6302 | 6310 |
| |
| |||
6310 | 6318 |
| |
6311 | 6319 |
| |
6312 | 6320 |
| |
6313 |
| - | |
6314 |
| - | |
6315 |
| - | |
6316 |
| - | |
6317 |
| - | |
6318 |
| - | |
6319 |
| - | |
6320 | 6321 |
| |
6321 | 6322 |
| |
6322 | 6323 |
| |
|
Lines changed: 13 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
174 | 174 |
| |
175 | 175 |
| |
176 | 176 |
| |
177 |
| - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
178 | 180 |
| |
179 | 181 |
| |
180 | 182 |
| |
181 | 183 |
| |
182 | 184 |
| |
183 | 185 |
| |
184 | 186 |
| |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
185 | 197 |
| |
186 | 198 |
| |
187 | 199 |
| |
|
0 commit comments
Comments
(0)