Commit b41b865
authored
Reduce notification timeout long tail (#990)
## Summary
- use a smaller candidate window for timestamp pagination so old
notification scrollback does not read tens of thousands of historical
rows before grouping
- give unread polling its own shorter timeout and return a conservative
capped unread response instead of surfacing a 504 when the
multi-recipient array path is cold
## Production evidence
- slow dEKBy cursor with the existing 25k candidate window read ~23.4k
rows and built ~2.9k groups before trimming
- the same cursor with a 2k candidate window still produced >600 groups
and planned/executed in ~51ms warm during read-only production probing
- unread timeout case for user 843 was dominated by the multi-recipient
GIN path scanning ~42k historical rows to find 7 current unread rows, so
this PR fails closed for the poll while we plan the
recipient-normalized/index follow-up
## Validation
- go test ./api -run '^$'
- git diff --check
## Notes
- go test ./api -run TestV1Notifications is blocked locally because
Postgres on localhost:21300 refused connections1 parent 86bd58d commit b41b865
1 file changed
Lines changed: 26 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
33 | 37 | | |
34 | 38 | | |
35 | 39 | | |
| |||
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
42 | 51 | | |
43 | 52 | | |
44 | 53 | | |
| |||
143 | 152 | | |
144 | 153 | | |
145 | 154 | | |
146 | | - | |
| 155 | + | |
147 | 156 | | |
148 | 157 | | |
149 | 158 | | |
| |||
158 | 167 | | |
159 | 168 | | |
160 | 169 | | |
161 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
162 | 181 | | |
163 | 182 | | |
164 | 183 | | |
| |||
578 | 597 | | |
579 | 598 | | |
580 | 599 | | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
581 | 604 | | |
582 | 605 | | |
583 | 606 | | |
| |||
592 | 615 | | |
593 | 616 | | |
594 | 617 | | |
595 | | - | |
| 618 | + | |
596 | 619 | | |
597 | 620 | | |
598 | 621 | | |
| |||
0 commit comments