forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit8aba932
committed
Fix relcache inconsistency hazard in partition detach
During queries coming from ri_triggers.c, we need to omit partitionsthat are marked pending detach -- otherwise, the RI query is trickedinto allowing a row into the referencing table whose corresponding rowis in the detached partition. Which is bogus: once the detach operationcompletes, the row becomes an orphan.However, the code was not doing that in repeatable-read transactions,because relcache kept a copy of the partition descriptor that includedthe partition, and used it in the RI query. This commit changes thepartdesc cache code to only keep descriptors that aren't dependent ona snapshot (namely: those where no detached partition exist, and thosewhere detached partitions are included). When a partdesc-without-detached-partitions is requested, we create one afresh each time; also,those partdescs are stored in PortalContext instead ofCacheMemoryContext.find_inheritance_children gets a new output *detached_exist boolean,which indicates whether any partition marked pending-detach is found.Its "include_detached" input flag is changed to "omit_detached", becausethat name captures desired the semantics more naturally.CreatePartitionDirectory() and RelationGetPartitionDesc() arguments areidentically renamed.This was noticed because a buildfarm member that runs with relcacheclobbering, which would not keep the improperly cached partdesc, brokeone test, which led us to realize that the expected output of that testwas bogus. This commit also corrects that expected output.Author: Amit Langote <amitlangote09@gmail.com>Author: Álvaro Herrera <alvherre@alvh.no-ip.org>Discussion:https://postgr.es/m/3269784.1617215412@sss.pgh.pa.us1 parent82b13db commit8aba932
File tree
12 files changed
+160
-101
lines changed- src
- backend
- catalog
- commands
- executor
- optimizer/util
- partitioning
- include
- catalog
- partitioning
- test/isolation/expected
12 files changed
+160
-101
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3840 | 3840 |
| |
3841 | 3841 |
| |
3842 | 3842 |
| |
3843 |
| - | |
| 3843 | + | |
3844 | 3844 |
| |
3845 | 3845 |
| |
3846 | 3846 |
| |
|
Lines changed: 39 additions & 24 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
52 | 52 |
| |
53 | 53 |
| |
54 | 54 |
| |
55 |
| - | |
56 |
| - | |
57 |
| - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
58 | 64 |
| |
59 | 65 |
| |
60 |
| - | |
61 |
| - | |
| 66 | + | |
| 67 | + | |
62 | 68 |
| |
63 | 69 |
| |
64 | 70 |
| |
| |||
78 | 84 |
| |
79 | 85 |
| |
80 | 86 |
| |
| 87 | + | |
| 88 | + | |
| 89 | + | |
81 | 90 |
| |
82 | 91 |
| |
83 | 92 |
| |
| |||
99 | 108 |
| |
100 | 109 |
| |
101 | 110 |
| |
102 |
| - | |
103 |
| - | |
104 |
| - | |
105 |
| - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
106 | 118 |
| |
107 |
| - | |
| 119 | + | |
108 | 120 |
| |
109 |
| - | |
110 |
| - | |
111 |
| - | |
| 121 | + | |
| 122 | + | |
112 | 123 |
| |
113 |
| - | |
114 |
| - | |
115 |
| - | |
| 124 | + | |
116 | 125 |
| |
117 |
| - | |
118 |
| - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
119 | 133 |
| |
120 |
| - | |
121 |
| - | |
| 134 | + | |
| 135 | + | |
122 | 136 |
| |
123 |
| - | |
124 |
| - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
125 | 140 |
| |
126 | 141 |
| |
127 | 142 |
| |
| |||
235 | 250 |
| |
236 | 251 |
| |
237 | 252 |
| |
238 |
| - | |
239 |
| - | |
| 253 | + | |
| 254 | + | |
240 | 255 |
| |
241 | 256 |
| |
242 | 257 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1123 | 1123 |
| |
1124 | 1124 |
| |
1125 | 1125 |
| |
1126 |
| - | |
| 1126 | + | |
1127 | 1127 |
| |
1128 | 1128 |
| |
1129 | 1129 |
| |
| |||
1180 | 1180 |
| |
1181 | 1181 |
| |
1182 | 1182 |
| |
1183 |
| - | |
| 1183 | + | |
1184 | 1184 |
| |
1185 | 1185 |
| |
1186 | 1186 |
| |
|
Lines changed: 20 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1041 | 1041 |
| |
1042 | 1042 |
| |
1043 | 1043 |
| |
1044 |
| - | |
| 1044 | + | |
1045 | 1045 |
| |
1046 | 1046 |
| |
1047 | 1047 |
| |
| |||
3507 | 3507 |
| |
3508 | 3508 |
| |
3509 | 3509 |
| |
3510 |
| - | |
| 3510 | + | |
3511 | 3511 |
| |
3512 | 3512 |
| |
3513 | 3513 |
| |
| |||
3706 | 3706 |
| |
3707 | 3707 |
| |
3708 | 3708 |
| |
3709 |
| - | |
| 3709 | + | |
3710 | 3710 |
| |
3711 | 3711 |
| |
3712 | 3712 |
| |
| |||
6580 | 6580 |
| |
6581 | 6581 |
| |
6582 | 6582 |
| |
6583 |
| - | |
| 6583 | + | |
6584 | 6584 |
| |
6585 | 6585 |
| |
6586 | 6586 |
| |
| |||
6826 | 6826 |
| |
6827 | 6827 |
| |
6828 | 6828 |
| |
6829 |
| - | |
| 6829 | + | |
6830 | 6830 |
| |
6831 | 6831 |
| |
6832 | 6832 |
| |
| |||
6980 | 6980 |
| |
6981 | 6981 |
| |
6982 | 6982 |
| |
6983 |
| - | |
| 6983 | + | |
6984 | 6984 |
| |
6985 | 6985 |
| |
6986 | 6986 |
| |
| |||
7689 | 7689 |
| |
7690 | 7690 |
| |
7691 | 7691 |
| |
7692 |
| - | |
| 7692 | + | |
7693 | 7693 |
| |
7694 | 7694 |
| |
7695 | 7695 |
| |
| |||
8297 | 8297 |
| |
8298 | 8298 |
| |
8299 | 8299 |
| |
8300 |
| - | |
| 8300 | + | |
8301 | 8301 |
| |
8302 | 8302 |
| |
8303 | 8303 |
| |
| |||
8785 | 8785 |
| |
8786 | 8786 |
| |
8787 | 8787 |
| |
8788 |
| - | |
| 8788 | + | |
8789 | 8789 |
| |
8790 | 8790 |
| |
8791 | 8791 |
| |
| |||
9400 | 9400 |
| |
9401 | 9401 |
| |
9402 | 9402 |
| |
9403 |
| - | |
| 9403 | + | |
9404 | 9404 |
| |
9405 | 9405 |
| |
9406 | 9406 |
| |
| |||
9534 | 9534 |
| |
9535 | 9535 |
| |
9536 | 9536 |
| |
9537 |
| - | |
| 9537 | + | |
9538 | 9538 |
| |
9539 | 9539 |
| |
9540 | 9540 |
| |
| |||
11318 | 11318 |
| |
11319 | 11319 |
| |
11320 | 11320 |
| |
11321 |
| - | |
11322 |
| - | |
| 11321 | + | |
| 11322 | + | |
11323 | 11323 |
| |
11324 | 11324 |
| |
11325 | 11325 |
| |
| |||
11703 | 11703 |
| |
11704 | 11704 |
| |
11705 | 11705 |
| |
11706 |
| - | |
11707 |
| - | |
| 11706 | + | |
| 11707 | + | |
11708 | 11708 |
| |
11709 | 11709 |
| |
11710 | 11710 |
| |
| |||
16875 | 16875 |
| |
16876 | 16876 |
| |
16877 | 16877 |
| |
16878 |
| - | |
| 16878 | + | |
16879 | 16879 |
| |
16880 | 16880 |
| |
16881 | 16881 |
| |
| |||
16935 | 16935 |
| |
16936 | 16936 |
| |
16937 | 16937 |
| |
16938 |
| - | |
| 16938 | + | |
16939 | 16939 |
| |
16940 | 16940 |
| |
16941 | 16941 |
| |
| |||
17551 | 17551 |
| |
17552 | 17552 |
| |
17553 | 17553 |
| |
17554 |
| - | |
| 17554 | + | |
17555 | 17555 |
| |
17556 | 17556 |
| |
17557 | 17557 |
| |
| |||
18148 | 18148 |
| |
18149 | 18149 |
| |
18150 | 18150 |
| |
18151 |
| - | |
| 18151 | + | |
18152 | 18152 |
| |
18153 | 18153 |
| |
18154 | 18154 |
| |
| |||
18302 | 18302 |
| |
18303 | 18303 |
| |
18304 | 18304 |
| |
18305 |
| - | |
| 18305 | + | |
18306 | 18306 |
| |
18307 | 18307 |
| |
18308 | 18308 |
| |
|
Lines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1119 | 1119 |
| |
1120 | 1120 |
| |
1121 | 1121 |
| |
1122 |
| - | |
| 1122 | + | |
1123 | 1123 |
| |
1124 | 1124 |
| |
1125 | 1125 |
| |
| |||
1141 | 1141 |
| |
1142 | 1142 |
| |
1143 | 1143 |
| |
1144 |
| - | |
1145 |
| - | |
| 1144 | + | |
| 1145 | + | |
1146 | 1146 |
| |
1147 | 1147 |
| |
1148 | 1148 |
| |
|
Lines changed: 8 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
991 | 991 |
| |
992 | 992 |
| |
993 | 993 |
| |
994 |
| - | |
995 |
| - | |
996 |
| - | |
997 |
| - | |
998 |
| - | |
999 |
| - | |
1000 |
| - | |
1001 |
| - | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
1002 | 999 |
| |
1003 | 1000 |
| |
1004 | 1001 |
| |
1005 | 1002 |
| |
1006 |
| - | |
| 1003 | + | |
1007 | 1004 |
| |
1008 | 1005 |
| |
1009 | 1006 |
| |
| |||
1571 | 1568 |
| |
1572 | 1569 |
| |
1573 | 1570 |
| |
1574 |
| - | |
| 1571 | + | |
1575 | 1572 |
| |
1576 | 1573 |
| |
1577 |
| - | |
| 1574 | + | |
1578 | 1575 |
| |
1579 | 1576 |
| |
1580 | 1577 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2200 | 2200 |
| |
2201 | 2201 |
| |
2202 | 2202 |
| |
2203 |
| - | |
| 2203 | + | |
2204 | 2204 |
| |
2205 | 2205 |
| |
2206 | 2206 |
| |
|
Lines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2798 | 2798 |
| |
2799 | 2799 |
| |
2800 | 2800 |
| |
2801 |
| - | |
| 2801 | + | |
2802 | 2802 |
| |
2803 | 2803 |
| |
2804 | 2804 |
| |
| |||
3991 | 3991 |
| |
3992 | 3992 |
| |
3993 | 3993 |
| |
3994 |
| - | |
| 3994 | + | |
3995 | 3995 |
| |
3996 | 3996 |
| |
3997 | 3997 |
| |
| |||
4191 | 4191 |
| |
4192 | 4192 |
| |
4193 | 4193 |
| |
4194 |
| - | |
| 4194 | + | |
4195 | 4195 |
| |
4196 | 4196 |
| |
4197 | 4197 |
| |
|
0 commit comments
Comments
(0)