fix(deployments): stop full scans and coalesce cache misses - #793
fix(deployments): stop full scans and coalesce cache misses#793romeroyonatan wants to merge 2 commits into
Conversation
|
|
| if createdAt == nil { | ||
| continue | ||
| } | ||
| if !createdAt.Before(from) && !createdAt.After(to) { |
There was a problem hiding this comment.
wouldn't createdAt.After(from) && createdAT.Before(to) be more idiomatic? also bear in mind that this is < not <= just in case
There was a problem hiding this comment.
For this PR, no: the requirement is inclusive [from, to].
!createdAt.Before(from) && !createdAt.After(to)means:
createdAt >= from && createdAt <= to
Using:
createdAt.After(from) && createdAt.Before(to)would mean:
createdAt > from && createdAt < to
and would incorrectly exclude deployments exactly at from or to.
The current form is idiomatic for inclusive time.Time bounds because Go has no
BetweenInclusive helper.
This pattern is also present in other code in this repo. For example:
https://github.com/grafana/github-datasource/blob/main/pkg/github/workflows.go#L102
Issue Deployment range queries scanned every GitHub page, and concurrent cache misses duplicated scans. Solution Paginate until deployments predate the requested range and coalesce identical deployment cache misses.
fc835ce to
805fc18
Compare
Issue
Solution
Implementation detail
singleflight.Grouptracks in-flight work by cache key, so identical misses share one request. The fielddeploymentRequests singleflight.Groupis deployment-specific because this PR intentionally changes only deployments