Commit c26d89e
committed
fix(messagequeue): stop unbounded heartbeat row growth
## Summary
### Why?
`queue_subscriber_heartbeats` rows are never removed: `Deregister` only soft-deletes (sets `deregistered_at`), crashed subscribers never deregister at all, and every process registers under a fresh `hostname-pid` subscriber name — so the table grows monotonically with nodes × subscriptions × deploys. `ActiveSubscribers` range-scans all rows for `(consumer_group, topic)`, so the dead rows slowly tax every fair-share computation.
### What?
- `Deregister` now hard-deletes the row. Subscriber names are unique per process, so a departed subscriber's row has no further use; re-subscribing re-inserts via the heartbeat upsert.
- New `PurgeStale` store method deletes rows whose heartbeat is older than a threshold; the subscriber calls it each lease tick with 10x `LeaseDurationMs` (5min at defaults) as the backstop for subscribers that crashed without deregistering. Purging a live-but-stalled subscriber's row is harmless — its next heartbeat re-inserts it.
- The `deregistered_at` column and its query filter are retained (no schema change) for compatibility with rows written by older code.
## Test Plan
- ✅ Integration: `TestRebalance_SubscriberLeaves` now also asserts the closed subscriber's heartbeat row is gone from the table.1 parent 474e9c9 commit c26d89e
7 files changed
Lines changed: 152 additions & 23 deletions
File tree
- platform/extension/messagequeue/mysql
- test/integration/extension/messagequeue/mysql
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
158 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
159 | 169 | | |
160 | 170 | | |
161 | 171 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
56 | 64 | | |
57 | 65 | | |
58 | 66 | | |
| |||
565 | 573 | | |
566 | 574 | | |
567 | 575 | | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
568 | 583 | | |
569 | 584 | | |
570 | 585 | | |
| |||
Lines changed: 35 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
105 | | - | |
| 104 | + | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
111 | | - | |
112 | 110 | | |
113 | | - | |
114 | | - | |
115 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
116 | 114 | | |
117 | 115 | | |
118 | 116 | | |
| |||
125 | 123 | | |
126 | 124 | | |
127 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
Lines changed: 67 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
| 175 | + | |
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | | - | |
182 | | - | |
183 | | - | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
184 | 185 | | |
185 | 186 | | |
186 | 187 | | |
187 | 188 | | |
188 | 189 | | |
189 | 190 | | |
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 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
191 | 243 | | |
192 | 244 | | |
193 | 245 | | |
| |||
199 | 251 | | |
200 | 252 | | |
201 | 253 | | |
202 | | - | |
203 | | - | |
204 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
205 | 257 | | |
206 | 258 | | |
207 | | - | |
| 259 | + | |
208 | 260 | | |
209 | 261 | | |
210 | | - | |
| 262 | + | |
211 | 263 | | |
212 | 264 | | |
213 | 265 | | |
| |||
230 | 282 | | |
231 | 283 | | |
232 | 284 | | |
233 | | - | |
234 | | - | |
| 285 | + | |
| 286 | + | |
235 | 287 | | |
236 | 288 | | |
237 | 289 | | |
238 | 290 | | |
239 | 291 | | |
240 | 292 | | |
241 | 293 | | |
242 | | - | |
243 | | - | |
| 294 | + | |
| 295 | + | |
244 | 296 | | |
245 | 297 | | |
246 | 298 | | |
247 | 299 | | |
248 | 300 | | |
249 | 301 | | |
250 | 302 | | |
251 | | - | |
252 | | - | |
| 303 | + | |
| 304 | + | |
253 | 305 | | |
254 | 306 | | |
255 | 307 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1814 | 1814 | | |
1815 | 1815 | | |
1816 | 1816 | | |
| 1817 | + | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
1817 | 1826 | | |
1818 | 1827 | | |
1819 | 1828 | | |
| |||
0 commit comments