forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit5c15606
committed
Fix several recently introduced issues around handling new relation forks.
Most of these stem fromd25f519 "tableam: relation creation, VACUUMFULL/CLUSTER, SET TABLESPACE.".1) To pass data to the relation_set_new_filenode() RelationSetNewRelfilenode() was made to update RelationData.rd_rel directly. That's not OK however, as it makes the relcache entries temporarily inconsistent. Which among other scenarios is a problem if a REINDEX targets an index on pg_class - the CatalogTupleUpdate() in RelationSetNewRelfilenode(). Presumably that was introduced because other places in the code do so - while those aren't "good practice" they don't appear to be actively buggy (e.g. because system tables may not be targeted). I (Andres) should have caught this while reviewing and signficantly evolving the code in that commit, mea culpa. Fix that by instead passing in the new RelFileNode as separate argument to relation_set_new_filenode() and rely on the relcache to update the catalog entry. Also revert that the RelationMapUpdateMap() call was changed to immediate, and undo some other more unnecessary changes.2) Document that the relation_set_new_filenode cannot rely on the whole relcache entry to be valid. It might be worthwhile to refactor the code to never have to rely on that, but given the way heap_create() is currently coded, that'd be a large change.3) ATExecSetTableSpace() shouldn't do FlushRelationBuffers() itself. A table AM might not use shared buffers at all. Move to index_copy_data() and heapam_relation_copy_data().4) heapam_relation_set_new_filenode() previously sometimes accessed rel->rd_rel->relpersistence rather than the `persistence` argument. Code movement mistake.5) Previously heapam_relation_set_new_filenode() re-opened the smgr relation to create the init for, if necesary. Instead have RelationCreateStorage() return the SMgrRelation and use it to create the init fork.6) Add a note about the danger of modifying the relcache directly to ATExecSetTableSpace() - it's currently not a bug because there's a check ERRORing for catalog tables.Regression tests and assertion improvements that together trigger thebug described in 1) will be added in a later commit, as there is arelated bug on all branches.Reported-By: Michael PaquierDiagnosed-By: Tom Lane and Andres FreundAuthor: Andres FreundReviewed-By: Tom LaneDiscussion:https://postgr.es/m/20190418011430.GA19133@paquier.xyz1 parent9ee7414 commit5c15606
File tree
8 files changed
+101
-61
lines changed- src
- backend
- access/heap
- catalog
- commands
- utils/cache
- include
- access
- catalog
8 files changed
+101
-61
lines changedLines changed: 24 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
566 | 566 |
| |
567 | 567 |
| |
568 | 568 |
| |
569 |
| - | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
570 | 572 |
| |
571 | 573 |
| |
572 | 574 |
| |
| 575 | + | |
| 576 | + | |
573 | 577 |
| |
574 | 578 |
| |
575 | 579 |
| |
| |||
587 | 591 |
| |
588 | 592 |
| |
589 | 593 |
| |
590 |
| - | |
| 594 | + | |
591 | 595 |
| |
592 | 596 |
| |
593 | 597 |
| |
| |||
598 | 602 |
| |
599 | 603 |
| |
600 | 604 |
| |
601 |
| - | |
| 605 | + | |
602 | 606 |
| |
603 | 607 |
| |
604 | 608 |
| |
605 | 609 |
| |
606 |
| - | |
607 |
| - | |
608 |
| - | |
609 |
| - | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
610 | 613 |
| |
| 614 | + | |
| 615 | + | |
611 | 616 |
| |
612 | 617 |
| |
613 | 618 |
| |
| |||
617 | 622 |
| |
618 | 623 |
| |
619 | 624 |
| |
620 |
| - | |
| 625 | + | |
621 | 626 |
| |
622 | 627 |
| |
623 | 628 |
| |
624 |
| - | |
| 629 | + | |
625 | 630 |
| |
626 | 631 |
| |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
627 | 640 |
| |
628 | 641 |
| |
629 | 642 |
| |
630 | 643 |
| |
631 | 644 |
| |
632 | 645 |
| |
633 | 646 |
| |
634 |
| - | |
| 647 | + | |
635 | 648 |
| |
636 | 649 |
| |
637 | 650 |
| |
| |||
652 | 665 |
| |
653 | 666 |
| |
654 | 667 |
| |
655 |
| - | |
| 668 | + | |
656 | 669 |
| |
657 | 670 |
| |
658 | 671 |
| |
|
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
435 | 435 |
| |
436 | 436 |
| |
437 | 437 |
| |
438 |
| - | |
439 |
| - | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
440 | 441 |
| |
441 | 442 |
| |
442 | 443 |
| |
|
Lines changed: 9 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
75 | 75 |
| |
76 | 76 |
| |
77 | 77 |
| |
78 |
| - | |
| 78 | + | |
79 | 79 |
| |
80 | 80 |
| |
81 | 81 |
| |
| |||
99 | 99 |
| |
100 | 100 |
| |
101 | 101 |
| |
102 |
| - | |
| 102 | + | |
103 | 103 |
| |
104 | 104 |
| |
105 | 105 |
| |
| |||
117 | 117 |
| |
118 | 118 |
| |
119 | 119 |
| |
| 120 | + | |
| 121 | + | |
120 | 122 |
| |
121 | 123 |
| |
122 | 124 |
| |
123 | 125 |
| |
124 | 126 |
| |
125 | 127 |
| |
126 |
| - | |
| 128 | + | |
127 | 129 |
| |
128 | 130 |
| |
129 | 131 |
| |
| |||
294 | 296 |
| |
295 | 297 |
| |
296 | 298 |
| |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
297 | 303 |
| |
298 | 304 |
| |
299 | 305 |
| |
|
Lines changed: 16 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
12236 | 12236 |
| |
12237 | 12237 |
| |
12238 | 12238 |
| |
12239 |
| - | |
12240 |
| - | |
12241 |
| - | |
12242 |
| - | |
12243 |
| - | |
12244 |
| - | |
12245 |
| - | |
12246 |
| - | |
12247 | 12239 |
| |
12248 | 12240 |
| |
12249 | 12241 |
| |
| |||
12266 | 12258 |
| |
12267 | 12259 |
| |
12268 | 12260 |
| |
12269 |
| - | |
| 12261 | + | |
12270 | 12262 |
| |
12271 | 12263 |
| |
12272 |
| - | |
| 12264 | + | |
| 12265 | + | |
| 12266 | + | |
| 12267 | + | |
| 12268 | + | |
| 12269 | + | |
| 12270 | + | |
12273 | 12271 |
| |
12274 | 12272 |
| |
12275 | 12273 |
| |
| |||
12537 | 12535 |
| |
12538 | 12536 |
| |
12539 | 12537 |
| |
| 12538 | + | |
| 12539 | + | |
| 12540 | + | |
| 12541 | + | |
| 12542 | + | |
| 12543 | + | |
| 12544 | + | |
| 12545 | + | |
12540 | 12546 |
| |
12541 | 12547 |
| |
12542 | 12548 |
| |
|
Lines changed: 29 additions & 26 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3440 | 3440 |
| |
3441 | 3441 |
| |
3442 | 3442 |
| |
| 3443 | + | |
3443 | 3444 |
| |
3444 | 3445 |
| |
3445 | 3446 |
| |
| |||
3462 | 3463 |
| |
3463 | 3464 |
| |
3464 | 3465 |
| |
3465 |
| - | |
3466 |
| - | |
3467 |
| - | |
3468 |
| - | |
3469 |
| - | |
3470 |
| - | |
3471 |
| - | |
3472 |
| - | |
3473 |
| - | |
3474 |
| - | |
3475 |
| - | |
3476 |
| - | |
3477 |
| - | |
3478 |
| - | |
3479 |
| - | |
3480 |
| - | |
3481 |
| - | |
| 3466 | + | |
| 3467 | + | |
3482 | 3468 |
| |
3483 | 3469 |
| |
3484 | 3470 |
| |
3485 | 3471 |
| |
3486 | 3472 |
| |
3487 | 3473 |
| |
3488 |
| - | |
3489 |
| - | |
| 3474 | + | |
| 3475 | + | |
3490 | 3476 |
| |
| 3477 | + | |
| 3478 | + | |
3491 | 3479 |
| |
3492 |
| - | |
3493 |
| - | |
3494 |
| - | |
3495 | 3480 |
| |
3496 | 3481 |
| |
3497 |
| - | |
| 3482 | + | |
3498 | 3483 |
| |
3499 | 3484 |
| |
3500 | 3485 |
| |
| |||
3505 | 3490 |
| |
3506 | 3491 |
| |
3507 | 3492 |
| |
3508 |
| - | |
3509 |
| - | |
| 3493 | + | |
| 3494 | + | |
| 3495 | + | |
| 3496 | + | |
| 3497 | + | |
| 3498 | + | |
3510 | 3499 |
| |
3511 | 3500 |
| |
3512 | 3501 |
| |
3513 | 3502 |
| |
3514 | 3503 |
| |
3515 |
| - | |
| 3504 | + | |
| 3505 | + | |
3516 | 3506 |
| |
3517 | 3507 |
| |
3518 | 3508 |
| |
3519 | 3509 |
| |
| 3510 | + | |
| 3511 | + | |
| 3512 | + | |
| 3513 | + | |
| 3514 | + | |
| 3515 | + | |
| 3516 | + | |
| 3517 | + | |
| 3518 | + | |
| 3519 | + | |
| 3520 | + | |
| 3521 | + | |
| 3522 | + | |
3520 | 3523 |
| |
3521 | 3524 |
| |
3522 | 3525 |
| |
|
Lines changed: 18 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
416 | 416 |
| |
417 | 417 |
| |
418 | 418 |
| |
419 |
| - | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
420 | 425 |
| |
421 | 426 |
| |
422 | 427 |
| |
423 | 428 |
| |
424 | 429 |
| |
425 | 430 |
| |
426 | 431 |
| |
| 432 | + | |
427 | 433 |
| |
428 | 434 |
| |
429 | 435 |
| |
| |||
444 | 450 |
| |
445 | 451 |
| |
446 | 452 |
| |
447 |
| - | |
| 453 | + | |
| 454 | + | |
448 | 455 |
| |
449 | 456 |
| |
450 | 457 |
| |
| |||
1251 | 1258 |
| |
1252 | 1259 |
| |
1253 | 1260 |
| |
1254 |
| - | |
| 1261 | + | |
1255 | 1262 |
| |
1256 | 1263 |
| |
1257 | 1264 |
| |
1258 |
| - | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
1259 | 1268 |
| |
1260 | 1269 |
| |
1261 | 1270 |
| |
1262 | 1271 |
| |
1263 | 1272 |
| |
1264 |
| - | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
1265 | 1276 |
| |
1266 | 1277 |
| |
1267 | 1278 |
| |
1268 |
| - | |
| 1279 | + | |
1269 | 1280 |
| |
1270 | 1281 |
| |
1271 | 1282 |
| |
| |||
1288 | 1299 |
| |
1289 | 1300 |
| |
1290 | 1301 |
| |
1291 |
| - | |
| 1302 | + | |
1292 | 1303 |
| |
1293 | 1304 |
| |
1294 | 1305 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
19 | 19 |
| |
20 | 20 |
| |
21 | 21 |
| |
22 |
| - | |
| 22 | + | |
23 | 23 |
| |
24 | 24 |
| |
25 | 25 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
50 | 50 |
| |
51 | 51 |
| |
52 | 52 |
| |
53 |
| - | |
| 53 | + | |
54 | 54 |
| |
55 | 55 |
| |
56 | 56 |
| |
|
0 commit comments
Comments
(0)