forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd7e39d7
committed
Use actual backend IDs in pg_stat_get_backend_idset() and friends.
Up to now, the ID values returned by pg_stat_get_backend_idset() andused by pg_stat_get_backend_activity() and allied functions were justindexes into a local array of sessions seen by the last stats refresh.This is problematic for a few reasons. The "ID" of a session can varyover its existence, which is surprising. Also, while these numbersoften match the "backend ID" used for purposes like temp schemaassignment, that isn't reliably true. We can fairly cheaply switchthings around to make these numbers actually be the sessions' backendIDs. The added test case illustrates that with this definition, thetemp schema used by a given session can be obtained given its PID.While here, delete some dead code that guarded against gettinga NULL return from pgstat_fetch_stat_local_beentry(). That can'thappen as long as the caller is careful to pass an in-range arrayindex, as all the callers are. (This code may not have been deadwhen written, but it surely is now.)Nathan BossartDiscussion:https://postgr.es/m/20220815205811.GA250990@nathanxps131 parentd5e3fe6 commitd7e39d7
File tree
6 files changed
+107
-51
lines changed- doc/src/sgml
- src
- backend/utils
- activity
- adt
- include/utils
- test/regress
- expected
- sql
6 files changed
+107
-51
lines changedLines changed: 11 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5485 | 5485 |
| |
5486 | 5486 |
| |
5487 | 5487 |
| |
5488 |
| - | |
| 5488 | + | |
5489 | 5489 |
| |
5490 | 5490 |
| |
5491 |
| - | |
5492 |
| - | |
| 5491 | + | |
| 5492 | + | |
| 5493 | + | |
| 5494 | + | |
| 5495 | + | |
5493 | 5496 |
| |
5494 |
| - | |
| 5497 | + | |
5495 | 5498 |
| |
5496 | 5499 |
| |
5497 | 5500 |
| |
5498 | 5501 |
| |
5499 |
| - | |
5500 |
| - | |
5501 |
| - | |
| 5502 | + | |
| 5503 | + | |
| 5504 | + | |
5502 | 5505 |
| |
5503 | 5506 |
| |
5504 | 5507 |
| |
| |||
5526 | 5529 |
| |
5527 | 5530 |
| |
5528 | 5531 |
| |
5529 |
| - | |
5530 |
| - | |
| 5532 | + | |
5531 | 5533 |
| |
5532 | 5534 |
| |
5533 | 5535 |
| |
|
Lines changed: 49 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
846 | 846 |
| |
847 | 847 |
| |
848 | 848 |
| |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
849 | 856 |
| |
850 | 857 |
| |
851 | 858 |
| |
| |||
1045 | 1052 |
| |
1046 | 1053 |
| |
1047 | 1054 |
| |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
1048 | 1070 |
| |
1049 | 1071 |
| |
1050 | 1072 |
| |
1051 | 1073 |
| |
1052 | 1074 |
| |
1053 |
| - | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
1054 | 1080 |
| |
1055 | 1081 |
| |
1056 | 1082 |
| |
1057 | 1083 |
| |
1058 | 1084 |
| |
1059 | 1085 |
| |
1060 |
| - | |
| 1086 | + | |
1061 | 1087 |
| |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
1062 | 1091 |
| |
1063 | 1092 |
| |
1064 |
| - | |
1065 |
| - | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
1066 | 1104 |
| |
1067 |
| - | |
| 1105 | + | |
1068 | 1106 |
| |
1069 | 1107 |
| |
1070 | 1108 |
| |
| |||
1074 | 1112 |
| |
1075 | 1113 |
| |
1076 | 1114 |
| |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
1077 | 1119 |
| |
1078 | 1120 |
| |
1079 | 1121 |
| |
| |||
1094 | 1136 |
| |
1095 | 1137 |
| |
1096 | 1138 |
| |
1097 |
| - | |
| 1139 | + | |
| 1140 | + | |
1098 | 1141 |
| |
1099 | 1142 |
| |
1100 | 1143 |
| |
|
Lines changed: 17 additions & 31 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
415 | 415 |
| |
416 | 416 |
| |
417 | 417 |
| |
418 |
| - | |
419 | 418 |
| |
420 | 419 |
| |
421 | 420 |
| |
| |||
424 | 423 |
| |
425 | 424 |
| |
426 | 425 |
| |
427 |
| - | |
| 426 | + | |
428 | 427 |
| |
429 | 428 |
| |
430 | 429 |
| |
431 |
| - | |
432 | 430 |
| |
433 | 431 |
| |
434 | 432 |
| |
435 | 433 |
| |
436 | 434 |
| |
437 | 435 |
| |
438 | 436 |
| |
439 |
| - | |
440 | 437 |
| |
441 |
| - | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
442 | 448 |
| |
443 | 449 |
| |
444 |
| - | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
445 | 453 |
| |
446 | 454 |
| |
447 | 455 |
| |
| |||
493 | 501 |
| |
494 | 502 |
| |
495 | 503 |
| |
496 |
| - | |
497 |
| - | |
498 |
| - | |
499 |
| - | |
500 | 504 |
| |
501 | 505 |
| |
502 | 506 |
| |
503 | 507 |
| |
504 | 508 |
| |
505 | 509 |
| |
506 |
| - | |
| 510 | + | |
507 | 511 |
| |
508 | 512 |
| |
509 | 513 |
| |
| |||
558 | 562 |
| |
559 | 563 |
| |
560 | 564 |
| |
561 |
| - | |
562 |
| - | |
563 |
| - | |
564 |
| - | |
565 |
| - | |
566 |
| - | |
567 |
| - | |
568 |
| - | |
569 |
| - | |
570 |
| - | |
571 |
| - | |
572 |
| - | |
573 |
| - | |
574 |
| - | |
575 |
| - | |
576 |
| - | |
577 |
| - | |
578 |
| - | |
579 | 565 |
| |
580 | 566 |
| |
581 | 567 |
| |
| |||
1180 | 1166 |
| |
1181 | 1167 |
| |
1182 | 1168 |
| |
1183 |
| - | |
| 1169 | + | |
1184 | 1170 |
| |
1185 |
| - | |
| 1171 | + | |
1186 | 1172 |
| |
1187 | 1173 |
| |
1188 | 1174 |
| |
|
Lines changed: 9 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
13 | 13 |
| |
14 | 14 |
| |
15 | 15 |
| |
| 16 | + | |
16 | 17 |
| |
17 | 18 |
| |
18 | 19 |
| |
| |||
247 | 248 |
| |
248 | 249 |
| |
249 | 250 |
| |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
250 | 258 |
| |
251 | 259 |
| |
252 | 260 |
| |
| |||
313 | 321 |
| |
314 | 322 |
| |
315 | 323 |
| |
316 |
| - | |
| 324 | + | |
317 | 325 |
| |
318 | 326 |
| |
319 | 327 |
| |
|
Lines changed: 13 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
576 | 576 |
| |
577 | 577 |
| |
578 | 578 |
| |
579 |
| - | |
| 579 | + | |
580 | 580 |
| |
581 |
| - | |
| 581 | + | |
582 | 582 |
| |
583 | 583 |
| |
584 | 584 |
| |
| |||
597 | 597 |
| |
598 | 598 |
| |
599 | 599 |
| |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
600 | 611 |
| |
601 | 612 |
| |
602 | 613 |
| |
|
Lines changed: 8 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
303 | 303 |
| |
304 | 304 |
| |
305 | 305 |
| |
306 |
| - | |
| 306 | + | |
307 | 307 |
| |
308 | 308 |
| |
309 |
| - | |
| 309 | + | |
310 | 310 |
| |
311 | 311 |
| |
312 | 312 |
| |
| |||
318 | 318 |
| |
319 | 319 |
| |
320 | 320 |
| |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
321 | 327 |
| |
322 | 328 |
| |
323 | 329 |
| |
|
0 commit comments
Comments
(0)