- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit6eedec1
committed
Protect against SnapshotNow race conditions in pg_tablespace scans.
Use of SnapshotNow is known to expose us to race conditions if the tuple(s)being sought could be updated by concurrently-committing transactions.CREATE DATABASE and DROP DATABASE are particularly exposed because they doheavyweight filesystem operations during their scans of pg_tablespace,so that the scans run for a very long time compared to most. Furthermore,the potential consequences of a missed or twice-visited row are nastierthan average:* createdb() could fail with a bogus "file already exists" error, or silently fail to copy one or more tablespace's worth of files into the new database.* remove_dbtablespaces() could miss one or more tablespaces, thus failing to free filesystem space for the dropped database.* check_db_file_conflict() could likewise miss a tablespace, leading to an OID conflict that could result in data loss either immediately or in future operations. (This seems of very low probability, though, since a duplicate database OID would be unlikely to start with.)Hence, it seems worth fixing these three places to use MVCC snapshots, eventhough this will someday be superseded by a generic solution to SnapshotNowrace conditions.Back-patch to all active branches.Stephen Frost and Tom Lane1 parent46dc33f commit6eedec1
1 file changed
+48
-3
lines changedLines changed: 48 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
107 | 107 |
| |
108 | 108 |
| |
109 | 109 |
| |
| 110 | + | |
110 | 111 |
| |
111 | 112 |
| |
112 | 113 |
| |
| |||
460 | 461 |
| |
461 | 462 |
| |
462 | 463 |
| |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
463 | 487 |
| |
464 | 488 |
| |
465 | 489 |
| |
| |||
477 | 501 |
| |
478 | 502 |
| |
479 | 503 |
| |
480 |
| - | |
| 504 | + | |
481 | 505 |
| |
482 | 506 |
| |
483 | 507 |
| |
| |||
1322 | 1346 |
| |
1323 | 1347 |
| |
1324 | 1348 |
| |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
1325 | 1360 |
| |
1326 | 1361 |
| |
1327 |
| - | |
| 1362 | + | |
1328 | 1363 |
| |
1329 | 1364 |
| |
1330 | 1365 |
| |
| |||
1391 | 1426 |
| |
1392 | 1427 |
| |
1393 | 1428 |
| |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
1394 | 1439 |
| |
1395 | 1440 |
| |
1396 |
| - | |
| 1441 | + | |
1397 | 1442 |
| |
1398 | 1443 |
| |
1399 | 1444 |
| |
|
0 commit comments
Comments
(0)