forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit4f2458d
committed
Use a safer method for determining whether relcache init file is stale.
When we invalidate the relcache entry for a system catalog or index, wemust also delete the relcache "init file" if the init file contains a copyof that rel's entry. The old way of doing this relied on a speciallymaintained list of the OIDs of relations present in the init file: we madethe list either when reading the file in, or when writing the file out.The problem is that when writing the file out, we included only relspresent in our local relcache, which might have already suffered somedeletions due to relcache inval events. In such cases we correctly decidednot to overwrite the real init file with incomplete data --- but we stillused the incomplete initFileRelationIds list for the rest of the currentsession. This could result in wrong decisions about whether the session'sown actions require deletion of the init file, potentially allowing an initfile created by some other concurrent session to be left around even thoughit's been made stale.Since we don't support changing the schema of a system catalog at runtime,the only likely scenario in which this would cause a problem in the fieldinvolves a "vacuum full" on a catalog concurrently with other activity, andeven then it's far from easy to provoke. Remarkably, this has been brokensince 2002 (in commit7863404), but we hadnever seen a reproducible test case until recently. If it did happen inthe field, the symptoms would probably involve unexpected "cache lookupfailed" errors to begin with, then "could not open file" failures after thenext checkpoint, as all accesses to the affected catalog stopped working.Recovery would require manually removing the stale "pg_internal.init" file.To fix, get rid of the initFileRelationIds list, and instead consultsyscache.c's list of relations used in catalog caches to decide whether arelation is included in the init file. This should be a tad more efficientanyway, since we're replacing linear search of a list with ~100 entrieswith a binary search. It's a bit ugly that the init file contents are nowso directly tied to the catalog caches, but in practice that won't makemuch difference.Back-patch to all supported branches.1 parentac86eda commit4f2458d
File tree
5 files changed
+96
-48
lines changed- src
- backend/utils/cache
- include/utils
5 files changed
+96
-48
lines changedLines changed: 5 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
461 | 461 |
| |
462 | 462 |
| |
463 | 463 |
| |
464 |
| - | |
| 464 | + | |
465 | 465 |
| |
| 466 | + | |
| 467 | + | |
| 468 | + | |
466 | 469 |
| |
467 |
| - | |
| 470 | + | |
468 | 471 |
| |
469 | 472 |
| |
470 | 473 |
| |
|
Lines changed: 17 additions & 40 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 | 133 |
| |
142 | 134 |
| |
143 | 135 |
| |
| |||
3190 | 3182 |
| |
3191 | 3183 |
| |
3192 | 3184 |
| |
3193 |
| - | |
3194 |
| - | |
3195 |
| - | |
3196 | 3185 |
| |
3197 | 3186 |
| |
3198 | 3187 |
| |
| |||
4477 | 4466 |
| |
4478 | 4467 |
| |
4479 | 4468 |
| |
4480 |
| - | |
4481 |
| - | |
4482 |
| - | |
4483 |
| - | |
4484 | 4469 |
| |
4485 | 4470 |
| |
4486 | 4471 |
| |
| |||
4517 | 4502 |
| |
4518 | 4503 |
| |
4519 | 4504 |
| |
4520 |
| - | |
4521 | 4505 |
| |
4522 | 4506 |
| |
| 4507 | + | |
| 4508 | + | |
| 4509 | + | |
| 4510 | + | |
| 4511 | + | |
| 4512 | + | |
| 4513 | + | |
4523 | 4514 |
| |
4524 | 4515 |
| |
4525 | 4516 |
| |
| |||
4579 | 4570 |
| |
4580 | 4571 |
| |
4581 | 4572 |
| |
| 4573 | + | |
| 4574 | + | |
| 4575 | + | |
| 4576 | + | |
| 4577 | + | |
| 4578 | + | |
| 4579 | + | |
| 4580 | + | |
| 4581 | + | |
| 4582 | + | |
4582 | 4583 |
| |
4583 | 4584 |
| |
4584 | 4585 |
| |
| |||
4635 | 4636 |
| |
4636 | 4637 |
| |
4637 | 4638 |
| |
4638 |
| - | |
4639 |
| - | |
4640 |
| - | |
4641 |
| - | |
4642 |
| - | |
4643 |
| - | |
4644 |
| - | |
4645 |
| - | |
4646 |
| - | |
4647 | 4639 |
| |
4648 | 4640 |
| |
4649 | 4641 |
| |
| |||
4702 | 4694 |
| |
4703 | 4695 |
| |
4704 | 4696 |
| |
4705 |
| - | |
4706 |
| - | |
4707 |
| - | |
4708 |
| - | |
4709 |
| - | |
4710 |
| - | |
4711 |
| - | |
4712 |
| - | |
4713 |
| - | |
4714 |
| - | |
4715 |
| - | |
4716 |
| - | |
4717 |
| - | |
4718 |
| - | |
4719 |
| - | |
4720 | 4697 |
| |
4721 | 4698 |
| |
4722 | 4699 |
| |
|
Lines changed: 71 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
791 | 791 |
| |
792 | 792 |
| |
793 | 793 |
| |
794 |
| - | |
795 |
| - | |
796 |
| - | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
797 | 798 |
| |
798 | 799 |
| |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
799 | 806 |
| |
800 | 807 |
| |
801 | 808 |
| |
| |||
809 | 816 |
| |
810 | 817 |
| |
811 | 818 |
| |
| 819 | + | |
| 820 | + | |
812 | 821 |
| |
813 | 822 |
| |
814 | 823 |
| |
815 |
| - | |
| 824 | + | |
816 | 825 |
| |
817 | 826 |
| |
818 | 827 |
| |
| |||
825 | 834 |
| |
826 | 835 |
| |
827 | 836 |
| |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
828 | 853 |
| |
| 854 | + | |
| 855 | + | |
829 | 856 |
| |
830 | 857 |
| |
831 | 858 |
| |
| |||
1113 | 1140 |
| |
1114 | 1141 |
| |
1115 | 1142 |
| |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + |
Lines changed: 0 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
105 | 105 |
| |
106 | 106 |
| |
107 | 107 |
| |
108 |
| - | |
109 | 108 |
| |
110 | 109 |
| |
111 | 110 |
| |
|
Lines changed: 3 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
18 | 18 |
| |
19 | 19 |
| |
20 | 20 |
| |
21 |
| - | |
| 21 | + | |
22 | 22 |
| |
23 | 23 |
| |
24 | 24 |
| |
| |||
125 | 125 |
| |
126 | 126 |
| |
127 | 127 |
| |
| 128 | + | |
| 129 | + | |
128 | 130 |
| |
129 | 131 |
| |
130 | 132 |
| |
|
0 commit comments
Comments
(0)