Commit 424e6fe
fix: add unique index on retained.topic to prevent COLLSCAN stalls (#91)
Without an index on `retained.topic`, every storeRetained upsert and
createRetainedStreamCombi lookup falls back to a collection scan. Under
load, the ordered bulkWrite in storeRetained serializes the whole
publish pipeline behind those scans, stalling broker.publish callbacks
by tens of seconds on deployments with thousands of retained topics
(observed: ~60s uniform lag with 15k retained + 200 msg/s).
The index is declared `unique` to match the {topic}-filtered upsert
semantics. Also extends the index factory to honor the `unique` flag.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent fd20510 commit 424e6fe
1 file changed
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
168 | 171 | | |
169 | 172 | | |
170 | 173 | | |
| |||
188 | 191 | | |
189 | 192 | | |
190 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
191 | 207 | | |
192 | 208 | | |
193 | 209 | | |
| |||
0 commit comments