Commit e1e4929
authored
Report waiting time only for currently waiting clients (#678)
The pool maxwait metric currently operates differently from Pgbouncer.
The way it operates today is that we keep track of max_wait on each connected client, when SHOW POOLS query is made, we go over the connected clients and we get the max of max_wait times among clients. This means the pool maxwait will never reset, it will always be monotonically increasing until the client with the highest maxwait disconnects.
This PR changes this behavior, by keeping track of the wait_start time on each client, when a client goes into WAITING state, we record the time offset from connect_time. When we either successfully or unsuccessfully checkout a connection from the pool, we reset the wait_start time.
When SHOW POOLS query is made, we go over all connected clients and we only consider clients whose wait_start is non-zero, for clients that have non-zero wait times, we compare them and report the maximum waiting time as maxwait for the pool.1 parent dc4d6ed commit e1e4929
4 files changed
+55
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
769 | 769 | | |
770 | 770 | | |
771 | 771 | | |
772 | | - | |
773 | 772 | | |
774 | 773 | | |
775 | 774 | | |
| |||
788 | 787 | | |
789 | 788 | | |
790 | 789 | | |
791 | | - | |
| 790 | + | |
792 | 791 | | |
793 | 792 | | |
794 | 793 | | |
| |||
802 | 801 | | |
803 | 802 | | |
804 | 803 | | |
805 | | - | |
| 804 | + | |
806 | 805 | | |
807 | 806 | | |
808 | 807 | | |
| |||
814 | 813 | | |
815 | 814 | | |
816 | 815 | | |
817 | | - | |
818 | | - | |
819 | | - | |
820 | | - | |
| 816 | + | |
821 | 817 | | |
822 | 818 | | |
823 | 819 | | |
| |||
843 | 839 | | |
844 | 840 | | |
845 | 841 | | |
846 | | - | |
| 842 | + | |
847 | 843 | | |
848 | 844 | | |
849 | 845 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
44 | 49 | | |
45 | 50 | | |
46 | 51 | | |
| |||
64 | 69 | | |
65 | 70 | | |
66 | 71 | | |
| 72 | + | |
67 | 73 | | |
68 | 74 | | |
69 | 75 | | |
| |||
111 | 117 | | |
112 | 118 | | |
113 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
114 | 123 | | |
115 | 124 | | |
116 | 125 | | |
| |||
122 | 131 | | |
123 | 132 | | |
124 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
125 | 141 | | |
126 | 142 | | |
127 | 143 | | |
| |||
130 | 146 | | |
131 | 147 | | |
132 | 148 | | |
133 | | - | |
134 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
135 | 155 | | |
136 | | - | |
| 156 | + | |
137 | 157 | | |
138 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
139 | 169 | | |
140 | 170 | | |
141 | 171 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
69 | 72 | | |
70 | 73 | | |
71 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
236 | | - | |
| 236 | + | |
| 237 | + | |
237 | 238 | | |
238 | 239 | | |
239 | 240 | | |
| 241 | + | |
240 | 242 | | |
241 | 243 | | |
242 | 244 | | |
243 | 245 | | |
244 | 246 | | |
245 | 247 | | |
246 | | - | |
| 248 | + | |
247 | 249 | | |
248 | 250 | | |
249 | 251 | | |
| |||
255 | 257 | | |
256 | 258 | | |
257 | 259 | | |
| 260 | + | |
258 | 261 | | |
259 | 262 | | |
260 | 263 | | |
261 | 264 | | |
262 | | - | |
263 | | - | |
264 | | - | |
| 265 | + | |
265 | 266 | | |
266 | | - | |
| 267 | + | |
267 | 268 | | |
268 | | - | |
269 | | - | |
| 269 | + | |
270 | 270 | | |
271 | | - | |
| 271 | + | |
272 | 272 | | |
| 273 | + | |
273 | 274 | | |
| 275 | + | |
| 276 | + | |
274 | 277 | | |
275 | 278 | | |
276 | 279 | | |
| |||
0 commit comments