Repository navigation
AI-3373: send the unowned usage alert at most once a day - #2115
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
kanat
left a comment
There was a problem hiding this comment.
Reviewed 8caa583 merged onto main bb12cb4. CI: all checks pass. go vet, gofmt, go test -race ./internal/alerts/ ./internal/routing/: clean.
Checked and sound:
- Every alert other than
unownedkeepsOptions.Limit: onlyrouting/alerts.go:66setsRepeat. A 48 h tick run of a flappingCheckcondition and anItemscondition withRepeatzero sends the same events at the same ticks on base and head. - The first event of a spell is not held back (7m30s on base and head).
- Breaking
repeat()back toLimitgives 5 and 4 events, as the description says. 14 mutations tried; the only survivor (!= 0to> 0) is equivalent. - Multi-pod:
usageUnownedonly rises on the pod that holds the shard's ship lock (sweeper.go:134-141,:224). So the rate is about 1 event a day per shard, plus one each time the lock moves or the pod restarts.
[Nit] R1.2 acceleration/internal/routing/alerts.go:47-48: the Alerts doc still says the loop "sends one event of a condition at most every limit". That is no longer true for unowned. Fix: add "or its Repeat".
[Nit] R1.4 In the description's table, the row "Level, 15-minute hold: warn, 15 min" is wrong. The first event goes out 7m30s after rows start waiting, on base and on head: IncreasingFor holds once both halves of the 15 min span rose. This PR does not change it; only the row is wrong.
[Nit] R1.6 There is no CHANGELOG.md entry. #2093 added one for the same alerts.
[Question] R1.5 AI-3373 also asks for the app's name, one Sentry issue per app, a plain-words message, and a count of rows rather than skips. This PR changes only the repeat rate. The description does not claim to close the ticket. Is it a first step, with the ticket kept open after merge? The title and branch name it, so Linear may close the ticket when this merges.
Verdict: request changes, for R1.1 (a new spell of unowned within 24 h is held back, or never sent).
|
Replies to the review's other items:
|
kanat
left a comment
There was a problem hiding this comment.
Delta round 2: 5194c50 merged onto main 9edddca. CI: 24 checks pass. gofmt, go vet, go test -race ./internal/alerts/ ./internal/routing/: clean.
R1.1 (thread 4630713072): fixed. I reran the round-1 probe on the condition as routing/alerts.go:66 builds it (rows wait 0-1 h and 3-5 h):
- Base (no
Repeat): second spell first sent at 3h07m30s. Head: 7m30s, then 3h07m30s. Same as base. - Second spell lasting to 30 h: head sends at 3h07m30s and again at 27h07m30s, 24 h after the send (round 1: 24h07m30s).
ItemswithRepeat: 24h: itemaaway 1-3 h goes out at 0, 3 h, 27 h; itembthat never went away goes out at 0 and 24 h. So per-item forgetting works, which #2118 needs for anItemsunowned.- Other alerts: a 48 h run of a flapping
Checkand anItemscondition withoutRepeatgives 5764 events with the same md5 ofmessage@offset(1624c93d…) on base and head. - Mutations of the new lines: no forget in
check(), forget onRepeat == 0, forget unconditionally, wrong key, no forget incheckItems(), forget of held items, forget of all items, prefix without:, wrong key to delete: all killed. One survives, below.
R1.3 (thread 4630713084; R1.2 in my numbering): fixed. The Repeat doc at alerts.go:61-67 says a check given the loop's limit must be given the Repeat. R1.3 (routing Alerts doc), R1.4 (description row), R1.5 (CHANGELOG) are fixed as well. R1.6 stays a question: partial step, ticket stays open.
New finding below (a test gap in the new code). Verdict: request changes for that one test; no code change needed.
Resolved acceleration/internal/alerts/alerts.go: the repeat interval per condition stays, and the hold counter from main counts before the repeat check. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWVEMob5wtaNHdUCC1msgG
|
This branch was taken over per Kanat: main is merged in (e8ede60, a merge commit, no history rewritten). Resolved: N7 is covered by 49098cf ( The failing check (integration (api), 11-20) was in |
kanat
left a comment
There was a problem hiding this comment.
VERDICT: GO
Delta round 3: e8ede60 (Ali's 49098cf plus the merge of main c2a4067). Checked: gofmt, go vet (with and without -tags integration), go test -race ./internal/alerts ./internal/routing, and -tags integration on both packages with my own test database.
N7 (thread 4641863031): fixed. TestAnItemOfAConditionWithoutARepeatKeepsTheLimitAcrossSpells (alerts_test.go:175). On the merged code, I changed checkItems's if condition.Repeat != 0 { to if true {. That test failed, and so did TestTheEventsSentAndTheirLimitAreAsTheyWere. Restored.
Earlier findings: R1.1 and R1.3 were closed in round 2. N7 was the only open one, and it is closed now. R1.6 (CHANGELOG) is covered by the entry in this PR.
Merge conflict in alerts.go (git show --remerge-diff e8ede60): resolved correctly.
- Main's
router_alert_holds_totalis kept in both paths.check()creates the counter before the!heldbranch, so the series exists at 0, and increments it before the repeat check.checkItems()addslen(held)before the forget. - Ali's per-condition
Repeatis kept: the forget when a condition stops holding, the forget of items that went away, andl.repeat(condition)in both paths. - Ali's local
holdswould have shadowed the package counterholds, so it is nowstill. No conflict marker is left. - I broke each of these on the merged head and each break fails a test:
checkItemsAddremoved,check()Incremoved (compiled as_ = counter),check()forget removed,check()repeat(condition)replaced withLimit. All 5 mutations were killed.
Tests: ./internal/alerts passes with -race and with -tags integration. ./internal/routing passes with -race. With -tags integration -p 1, the full package passed in 3 of 5 runs. The other two runs failed TestWriterSuite/TestAStuckHolderGivesUpAndEveryRouterStillCountsWhatWaits (shipper_test.go:67, a test with a 1 s sweep timeout). The machine load was about 47 at the time. This delta does not touch the shipper. TestWriterSuite passed 3 of 3 runs on its own, and the next two full runs passed.
CI (gh pr checks, read once): the integration jobs and go were still pending on the new head. Analyze (python), Analyze (actions), labeler and GitGuardian pass. The orchestrator waits for the rest.
No new findings.
kanat
left a comment
There was a problem hiding this comment.
Approving on the reviewer's GO (take-over of Ali's PR per Kanat; delta review #2115 (review)).
UnownedUsage moves to the Requests repository (main split Store); the unowned condition keeps per-item names and the 24 h Repeat of #2115. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWVEMob5wtaNHdUCC1msgG
Why
The
unownedusage alert holds for as long as one usage row waits for an organization, which can be days. The alerts loop sends a condition that holds at most once perOptions.Limit, one minute for every condition, sounownedwent out about 1440 times a day.How it works
For an
Itemscondition the same holds per item: an item that is no longer held loses its last send, so it goes out at once when it comes back.Condition.Repeat,Loop.repeat(acceleration/internal/alerts/alerts.go:68,:189)Repeatthat keeps holding is held back for it, not forLimitTestAConditionWithItsOwnRepeatIsSentAgainOnlyAfterItcheckItemsusesrepeat(condition)(acceleration/internal/alerts/alerts.go:176)Itemscondition is held back for theRepeatTestAnItemOfAConditionWithItsOwnRepeatIsSentAgainOnlyAfterItRepeatcondition stops holding (acceleration/internal/alerts/alerts.go:148)TestANewSpellOfAConditionWithItsOwnRepeatIsSentAtOnceacceleration/internal/alerts/alerts.go:169)TestAnItemThatComesBackIsSentAtOnceRepeatLimitacross spells, as before, and so do their itemsTestAConditionWithoutARepeatKeepsTheLimitAcrossSpells,TestAnItemOfAConditionWithoutARepeatKeepsTheLimitAcrossSpellsunownedgetsRepeat: 24 * time.Hour(acceleration/internal/routing/alerts.go:66)unownedrepeats once a dayTestOnlyUnownedRepeatsOnceADayunownedThe
Repeatdoc says a check given the loop's limit (IncreasedSinceAlert,IncreasedPer) must be given theRepeatinstead; no condition combines them today.Validation
go vet ./internal/alerts/ ./internal/routing/: clean.go test ./internal/alerts/ ./internal/routing/: pass.-raceonTestAlertsSuite: pass.TestAConditionWithItsOwnRepeatIsSentAgainOnlyAfterItandTestAnItemOfAConditionWithItsOwnRepeatIsSentAgainOnlyAfterItfailed on the old loop (5 and 4 events where 1 is expected): they catch a loop that ignoresRepeat, and one that never sends again after 24 h.TestANewSpellOfAConditionWithItsOwnRepeatIsSentAtOnceandTestAnItemThatComesBackIsSentAtOncefailed before the last send was forgotten (1 and 2 events where 2 and 3 are expected): they catch a new spell held back by the previous one's send.TestAConditionWithoutARepeatKeepsTheLimitAcrossSpellsandTestAnItemOfAConditionWithoutARepeatKeepsTheLimitAcrossSpellscatch forgetting the last send for every condition or every item, which would change the rate of the alerts this PR leaves alone. The item test fails with the forget made unconditional incheckItems(2 events where 1 is expected).TestOnlyUnownedRepeatsOnceADaycatchesunownedlosing its 24 h repeat, and any other alert picking one up.