Commit 6708e44
committed
Clean up shm_mq cleanup.
The logic around shm_mq_detach was a few bricks shy of a load, because
(contrary to the comments for shm_mq_attach) all it did was update the
shared shm_mq state. That left us leaking a bit of process-local
memory, but much worse, the on_dsm_detach callback for shm_mq_detach
was still armed. That means that whenever we ultimately detach from
the DSM segment, we'd run shm_mq_detach again for already-detached,
possibly long-dead queues. This accidentally fails to fail today,
because we only ever re-use a shm_mq's memory for another shm_mq, and
multiple detach attempts on the last such shm_mq are fairly harmless.
But it's gonna bite us someday, so let's clean it up.
To do that, change shm_mq_detach's API so it takes a shm_mq_handle
not the underlying shm_mq. This makes the callers simpler in most
cases anyway. Also fix a few places in parallel.c that were just
pfree'ing the handle structs rather than doing proper cleanup.
Back-patch to v10 because of the risk that the revenant shm_mq_detach
callbacks would cause a live bug sometime. Since this is an API
change, it's too late to do it in 9.6. (We could make a variant
patch that preserves API, but I'm not excited enough to do that.)
Discussion: https://postgr.es/m/8670.1504192177@sss.pgh.pa.us1 parent 4b1dd62 commit 6708e44
File tree
5 files changed
+51
-21
lines changed- src
- backend
- access/transam
- executor
- libpq
- storage/ipc
- include/storage
5 files changed
+51
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
480 | 480 | | |
481 | 481 | | |
482 | 482 | | |
483 | | - | |
| 483 | + | |
484 | 484 | | |
485 | 485 | | |
486 | 486 | | |
| |||
612 | 612 | | |
613 | 613 | | |
614 | 614 | | |
615 | | - | |
| 615 | + | |
616 | 616 | | |
617 | 617 | | |
618 | 618 | | |
| |||
861 | 861 | | |
862 | 862 | | |
863 | 863 | | |
864 | | - | |
| 864 | + | |
865 | 865 | | |
866 | 866 | | |
867 | 867 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
578 | 578 | | |
579 | 579 | | |
580 | 580 | | |
581 | | - | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
582 | 584 | | |
583 | 585 | | |
584 | 586 | | |
| |||
589 | 591 | | |
590 | 592 | | |
591 | 593 | | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
592 | 597 | | |
593 | 598 | | |
594 | 599 | | |
| |||
650 | 655 | | |
651 | 656 | | |
652 | 657 | | |
653 | | - | |
| 658 | + | |
654 | 659 | | |
655 | 660 | | |
656 | 661 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
| |||
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
59 | | - | |
60 | 58 | | |
61 | 59 | | |
62 | 60 | | |
| |||
70 | 68 | | |
71 | 69 | | |
72 | 70 | | |
73 | | - | |
74 | 71 | | |
75 | 72 | | |
76 | 73 | | |
| |||
135 | 132 | | |
136 | 133 | | |
137 | 134 | | |
138 | | - | |
139 | | - | |
140 | | - | |
| 135 | + | |
| 136 | + | |
141 | 137 | | |
142 | 138 | | |
143 | 139 | | |
| |||
148 | 144 | | |
149 | 145 | | |
150 | 146 | | |
151 | | - | |
| 147 | + | |
152 | 148 | | |
153 | 149 | | |
154 | 150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
87 | 89 | | |
88 | 90 | | |
89 | 91 | | |
| |||
139 | 141 | | |
140 | 142 | | |
141 | 143 | | |
| 144 | + | |
142 | 145 | | |
143 | 146 | | |
144 | 147 | | |
| |||
288 | 291 | | |
289 | 292 | | |
290 | 293 | | |
291 | | - | |
292 | 294 | | |
| 295 | + | |
293 | 296 | | |
294 | 297 | | |
295 | | - | |
296 | 298 | | |
| 299 | + | |
297 | 300 | | |
298 | 301 | | |
| 302 | + | |
299 | 303 | | |
300 | 304 | | |
301 | 305 | | |
| |||
765 | 769 | | |
766 | 770 | | |
767 | 771 | | |
768 | | - | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
769 | 794 | | |
770 | 795 | | |
771 | 796 | | |
772 | 797 | | |
773 | 798 | | |
774 | 799 | | |
775 | 800 | | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
776 | 805 | | |
777 | | - | |
778 | | - | |
| 806 | + | |
| 807 | + | |
779 | 808 | | |
780 | 809 | | |
781 | 810 | | |
| |||
1193 | 1222 | | |
1194 | 1223 | | |
1195 | 1224 | | |
1196 | | - | |
| 1225 | + | |
1197 | 1226 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
66 | | - | |
| 65 | + | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
0 commit comments