forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit089e4d4
committed
Prevent memory leaks associated with relcache rd_partcheck structures.
The original coding of generate_partition_qual() just copied the listof predicate expressions into the global CacheMemoryContext, making iteffectively impossible to clean up when the owning relcache entry isdestroyed --- the relevant code in RelationDestroyRelation() only managedto free the topmost List header :-(. This resulted in a session-lifespanmemory leak whenever a table partition's relcache entry is rebuilt.Fortunately, that's not normally a large data structure, and rebuildsshouldn't occur all that often in production situations; but this isstill a bug worth fixing back to v10 where the code was introduced.To fix, put the cached expression tree into its own small memory context,as we do with other complicated substructures of relcache entries.Also, deal more honestly with the case that a partition has an emptypartcheck list; while that probably isn't a case that's very interestingfor production use, it's legal.In passing, clarify comments about how partitioning-related relcachedata structures are managed, and add some Asserts that we're not leakingold copies when we overwrite these data fields.Amit Langote and Tom LaneDiscussion:https://postgr.es/m/7961.1552498252@sss.pgh.pa.us1 parent7ef2b31 commit089e4d4
File tree
3 files changed
+80
-30
lines changed- src
- backend/utils/cache
- include/utils
3 files changed
+80
-30
lines changedLines changed: 61 additions & 21 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
47 | 47 |
| |
48 | 48 |
| |
49 | 49 |
| |
50 |
| - | |
| 50 | + | |
51 | 51 |
| |
52 | 52 |
| |
53 | 53 |
| |
54 |
| - | |
| 54 | + | |
55 | 55 |
| |
56 | 56 |
| |
57 | 57 |
| |
| |||
150 | 150 |
| |
151 | 151 |
| |
152 | 152 |
| |
| 153 | + | |
153 | 154 |
| |
154 | 155 |
| |
155 | 156 |
| |
156 | 157 |
| |
157 | 158 |
| |
158 | 159 |
| |
159 | 160 |
| |
160 |
| - | |
161 |
| - | |
162 | 161 |
| |
163 | 162 |
| |
164 | 163 |
| |
| |||
241 | 240 |
| |
242 | 241 |
| |
243 | 242 |
| |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
244 | 247 |
| |
245 | 248 |
| |
246 | 249 |
| |
| |||
252 | 255 |
| |
253 | 256 |
| |
254 | 257 |
| |
255 |
| - | |
| 258 | + | |
256 | 259 |
| |
257 |
| - | |
258 |
| - | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
259 | 265 |
| |
260 | 266 |
| |
261 | 267 |
| |
| |||
565 | 571 |
| |
566 | 572 |
| |
567 | 573 |
| |
568 |
| - | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
569 | 587 |
| |
570 | 588 |
| |
571 |
| - | |
572 |
| - | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
573 | 592 |
| |
574 | 593 |
| |
575 | 594 |
| |
| |||
839 | 858 |
| |
840 | 859 |
| |
841 | 860 |
| |
842 |
| - | |
843 |
| - | |
844 |
| - | |
845 |
| - | |
846 |
| - | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
847 | 864 |
| |
848 | 865 |
| |
849 | 866 |
| |
| |||
860 | 877 |
| |
861 | 878 |
| |
862 | 879 |
| |
863 |
| - | |
864 |
| - | |
| 880 | + | |
| 881 | + | |
865 | 882 |
| |
866 | 883 |
| |
867 | 884 |
| |
| |||
907 | 924 |
| |
908 | 925 |
| |
909 | 926 |
| |
910 |
| - | |
911 |
| - | |
912 |
| - | |
913 |
| - | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
914 | 953 |
| |
915 | 954 |
| |
916 | 955 |
| |
917 | 956 |
| |
| 957 | + | |
918 | 958 |
| |
919 | 959 |
| |
920 | 960 |
| |
|
Lines changed: 13 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1191 | 1191 |
| |
1192 | 1192 |
| |
1193 | 1193 |
| |
1194 |
| - | |
1195 | 1194 |
| |
| 1195 | + | |
1196 | 1196 |
| |
1197 | 1197 |
| |
1198 | 1198 |
| |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
1199 | 1203 |
| |
1200 | 1204 |
| |
1201 | 1205 |
| |
| |||
2285 | 2289 |
| |
2286 | 2290 |
| |
2287 | 2291 |
| |
2288 |
| - | |
2289 |
| - | |
| 2292 | + | |
| 2293 | + | |
2290 | 2294 |
| |
2291 | 2295 |
| |
2292 | 2296 |
| |
| |||
5617 | 5621 |
| |
5618 | 5622 |
| |
5619 | 5623 |
| |
5620 |
| - | |
5621 |
| - | |
| 5624 | + | |
| 5625 | + | |
5622 | 5626 |
| |
5623 | 5627 |
| |
5624 | 5628 |
| |
5625 | 5629 |
| |
5626 | 5630 |
| |
5627 |
| - | |
5628 | 5631 |
| |
5629 |
| - | |
| 5632 | + | |
5630 | 5633 |
| |
| 5634 | + | |
5631 | 5635 |
| |
| 5636 | + | |
| 5637 | + | |
5632 | 5638 |
| |
5633 | 5639 |
| |
5634 | 5640 |
| |
|
Lines changed: 6 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
95 | 95 |
| |
96 | 96 |
| |
97 | 97 |
| |
98 |
| - | |
| 98 | + | |
99 | 99 |
| |
100 |
| - | |
| 100 | + | |
101 | 101 |
| |
102 | 102 |
| |
103 | 103 |
| |
| |||
188 | 188 |
| |
189 | 189 |
| |
190 | 190 |
| |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
191 | 195 |
| |
192 | 196 |
| |
193 | 197 |
| |
|
0 commit comments
Comments
(0)