forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit43620e3
committed
Add function to log the memory contexts of specified backend process.
Commit3e98c0b added pg_backend_memory_contexts view to displaythe memory contexts of the backend process. However its target processis limited to the backend that is accessing to the view. So this isnot so convenient when investigating the local memory bloat of otherbackend process. To improve this situation, this commit addspg_log_backend_memory_contexts() function that requests to logthe memory contexts of the specified backend process.This information can be also collected by callingMemoryContextStats(TopMemoryContext) via a debugger. Butthis technique cannot be used in some environments because no debuggeris available there. So, pg_log_backend_memory_contexts() allows us tosee the memory contexts of specified backend more easily.Only superusers are allowed to request to log the memory contextsbecause allowing any users to issue this request at an unbounded ratewould cause lots of log messages and which can lead to denial of service.On receipt of the request, at the next CHECK_FOR_INTERRUPTS(),the target backend logs its memory contexts at LOG_SERVER_ONLY level,so that these memory contexts will appear in the server log but notbe sent to the client. It logs one message per memory context.Because if it buffers all memory contexts into StringInfo to log themas one message, which may require the buffer to be enlarged very muchand lead to OOM error since there can be a large number of memorycontexts in a backend.When a backend process is consuming huge memory, logging all itsmemory contexts might overrun available disk space. To prevent this,now this patch limits the number of child contexts to log per parentto 100. As with MemoryContextStats(), it supposes that practical caseswhere the log gets long will typically be huge numbers of siblingsunder the same parent context; while the additional debugging valuefrom seeing details about individual siblings beyond 100 will not be large.There was another proposed patch to add the function to returnthe memory contexts of specified backend as the result sets,instead of logging them, in the discussion. However that patch isnot included in this commit because it had several issues to address.Thanks to Tatsuhito Kasahara, Andres Freund, Tom Lane, Tomas Vondra,Michael Paquier, Kyotaro Horiguchi and Zhihong Yu for the discussion.Bump catalog version.Author: Atsushi TorikoshiReviewed-by: Kyotaro Horiguchi, Zhihong Yu, Fujii MasaoDiscussion:https://postgr.es/m/0271f440ac77f2a4180e0e56ebd944d1@oss.nttdata.com1 parent5a71964 commit43620e3
File tree
17 files changed
+320
-48
lines changed- doc/src/sgml
- src
- backend
- storage/ipc
- tcop
- utils
- adt
- init
- mmgr
- include
- catalog
- nodes
- storage
- utils
- test/regress
- expected
- sql
17 files changed
+320
-48
lines changedLines changed: 52 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
24913 | 24913 |
| |
24914 | 24914 |
| |
24915 | 24915 |
| |
| 24916 | + | |
| 24917 | + | |
| 24918 | + | |
| 24919 | + | |
| 24920 | + | |
| 24921 | + | |
| 24922 | + | |
| 24923 | + | |
| 24924 | + | |
| 24925 | + | |
| 24926 | + | |
| 24927 | + | |
| 24928 | + | |
| 24929 | + | |
| 24930 | + | |
| 24931 | + | |
| 24932 | + | |
| 24933 | + | |
| 24934 | + | |
| 24935 | + | |
24916 | 24936 |
| |
24917 | 24937 |
| |
24918 | 24938 |
| |
| |||
24983 | 25003 |
| |
24984 | 25004 |
| |
24985 | 25005 |
| |
| 25006 | + | |
| 25007 | + | |
| 25008 | + | |
| 25009 | + | |
| 25010 | + | |
| 25011 | + | |
| 25012 | + | |
| 25013 | + | |
| 25014 | + | |
| 25015 | + | |
| 25016 | + | |
| 25017 | + | |
| 25018 | + | |
| 25019 | + | |
| 25020 | + | |
| 25021 | + | |
| 25022 | + | |
| 25023 | + | |
| 25024 | + | |
| 25025 | + | |
| 25026 | + | |
| 25027 | + | |
| 25028 | + | |
| 25029 | + | |
| 25030 | + | |
| 25031 | + | |
| 25032 | + | |
| 25033 | + | |
| 25034 | + | |
| 25035 | + | |
| 25036 | + | |
| 25037 | + | |
24986 | 25038 |
| |
24987 | 25039 |
| |
24988 | 25040 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
30 | 30 |
| |
31 | 31 |
| |
32 | 32 |
| |
| 33 | + | |
33 | 34 |
| |
34 | 35 |
| |
35 | 36 |
| |
| |||
657 | 658 |
| |
658 | 659 |
| |
659 | 660 |
| |
| 661 | + | |
| 662 | + | |
| 663 | + | |
660 | 664 |
| |
661 | 665 |
| |
662 | 666 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3327 | 3327 |
| |
3328 | 3328 |
| |
3329 | 3329 |
| |
| 3330 | + | |
| 3331 | + | |
| 3332 | + | |
3330 | 3333 |
| |
3331 | 3334 |
| |
3332 | 3335 |
| |
|
Lines changed: 59 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
18 | 18 |
| |
19 | 19 |
| |
20 | 20 |
| |
| 21 | + | |
| 22 | + | |
21 | 23 |
| |
22 | 24 |
| |
23 | 25 |
| |
| |||
61 | 63 |
| |
62 | 64 |
| |
63 | 65 |
| |
64 |
| - | |
| 66 | + | |
65 | 67 |
| |
66 | 68 |
| |
67 | 69 |
| |
| |||
155 | 157 |
| |
156 | 158 |
| |
157 | 159 |
| |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + |
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
35 | 35 |
| |
36 | 36 |
| |
37 | 37 |
| |
| 38 | + | |
38 | 39 |
| |
39 | 40 |
| |
40 | 41 |
| |
|
Lines changed: 5 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
272 | 272 |
| |
273 | 273 |
| |
274 | 274 |
| |
275 |
| - | |
| 275 | + | |
| 276 | + | |
276 | 277 |
| |
277 | 278 |
| |
278 | 279 |
| |
| |||
1336 | 1337 |
| |
1337 | 1338 |
| |
1338 | 1339 |
| |
| 1340 | + | |
1339 | 1341 |
| |
1340 | 1342 |
| |
1341 | 1343 |
| |
1342 | 1344 |
| |
1343 |
| - | |
| 1345 | + | |
1344 | 1346 |
| |
1345 | 1347 |
| |
1346 | 1348 |
| |
| |||
1379 | 1381 |
| |
1380 | 1382 |
| |
1381 | 1383 |
| |
1382 |
| - | |
| 1384 | + | |
1383 | 1385 |
| |
1384 | 1386 |
| |
1385 | 1387 |
| |
|
Lines changed: 5 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
155 | 155 |
| |
156 | 156 |
| |
157 | 157 |
| |
158 |
| - | |
| 158 | + | |
| 159 | + | |
159 | 160 |
| |
160 | 161 |
| |
161 | 162 |
| |
| |||
665 | 666 |
| |
666 | 667 |
| |
667 | 668 |
| |
| 669 | + | |
668 | 670 |
| |
669 | 671 |
| |
670 | 672 |
| |
671 | 673 |
| |
672 | 674 |
| |
673 | 675 |
| |
674 | 676 |
| |
675 |
| - | |
| 677 | + | |
676 | 678 |
| |
677 | 679 |
| |
678 | 680 |
| |
| |||
704 | 706 |
| |
705 | 707 |
| |
706 | 708 |
| |
707 |
| - | |
| 709 | + | |
708 | 710 |
| |
709 | 711 |
| |
710 | 712 |
| |
|
0 commit comments
Comments
(0)