Repository navigation
Crashes: count the daily limits on the clock that stamps the event - #414
Merged
Merged
Conversation
Insert counted a client's and a camera's crashes since a.now() - 24h, but stamped each event with the database's now(). With the API's clock and the database's apart -- as in TestMonthCap, whose clock is fixed at 2026-10-08 12:00 UTC -- the window counted the wrong events: from 17:00 UTC that day the test's earlier sends all fell inside it and the sixth was refused 429, so master's CI fails from then on, on every day. Insert now takes the event's time, stamps received_at with it, and counts the day before it: the window and what it counts come from one clock.
PR Summary by QodoAlign crash quota windows with event timestamps
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can keep summaries lean with Findings visible per group, which tucks the rest behind a View link |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Master's CI is failing
TestMonthCap(internal/crashes, #411) since 17:00 UTC today, on master's own code and on every branch.Cause:
Store.Insertcounted a client's and a camera's crashes sincea.now() - 24h, but stamped each event with the database'snow(). When the API's clock and the database's differ, the window counts the wrong events. InTestMonthCapthe clock is fixed at 2026-10-08 12:00 UTC and steps 5 hours per send. From 17:00 UTC that day, the test's earlier sends all fall inside the window, so the sixth is refused with 429. From then on it fails on every day.Fix:
Inserttakes the event's time, stampsreceived_atwith it, and counts the 24 hours before it. The window and what it counts now come from one clock. In production both clocks are the server's, so behaviour is unchanged.Tests:
TestMonthCapfails once684afat 18:07 UTC and passes with this change at 18:09 UTC. The fullservice/run.sh testpasses (23 packages), and gofmt is clean.