fix(watchdog): attach heap profile and memstats to heap_pressure alerts (HUB-2) #105
Open
bot
wants to merge 1 commit from
fix/HUB-2-heap-profile-attachment into fix/HUB-3-watchdog-sustained-breach
pull from: fix/HUB-2-heap-profile-attachment
merge into: pokebedrock:fix/HUB-3-watchdog-sustained-breach
pokebedrock:main
pokebedrock:fix/HUB-3-watchdog-sustained-breach
pokebedrock:feat/content-creator-beta-access
pokebedrock:feat/split-res-packs
pokebedrock:feat/rogue-experience
pokebedrock:fleet-admin-ui
pokebedrock:remove-udp-relays
pokebedrock:migrate-to-new-website
pokebedrock:dependabot/go_modules/github.com/getsentry/sentry-go-0.48.0
pokebedrock:dev-servers
pokebedrock:dependabot/go_modules/go_modules-607a02e571
pokebedrock:dependabot/github_actions/actions/setup-go-7
pokebedrock:dependabot/go_modules/github.com/sandertv/gophertunnel-1.57.1
pokebedrock:dependabot/go_modules/github.com/df-mc/dragonfly-0.11.0
pokebedrock:dependabot/go_modules/golang.org/x/term-0.45.0
pokebedrock:dependabot/go_modules/golang.org/x/text-0.40.0
pokebedrock:v0.11.0-migration
pokebedrock:dependabot/go_modules/github.com/schollz/progressbar/v3-3.19.1
pokebedrock:dependabot/go_modules/github.com/sandertv/go-raknet-1.15.1
pokebedrock:dependabot/github_actions/actions/checkout-7
pokebedrock:dependabot/github_actions/actions/setup-go-6
pokebedrock:dependabot/github_actions/softprops/action-gh-release-3
pokebedrock:great-improvements-and-cleanup
pokebedrock:dependabot/go_modules/golang.org/x/text-0.38.0
pokebedrock:dependabot/go_modules/go_modules-c3a371b575
pokebedrock:dependabot/go_modules/golang.org/x/text-0.37.0
pokebedrock:dependabot/go_modules/github.com/getsentry/sentry-go-0.46.2
pokebedrock:dependabot/go_modules/github.com/getsentry/sentry-go-0.46.0
pokebedrock:improve-afk
pokebedrock:dependabot/go_modules/golang.org/x/text-0.36.0
pokebedrock:dependabot/go_modules/github.com/getsentry/sentry-go-0.45.1
pokebedrock:dependabot/go_modules/go_modules-a978bc362c
pokebedrock:dependabot/go_modules/golang.org/x/text-0.35.0
pokebedrock:dependabot/go_modules/github.com/samber/lo-1.53.0
pokebedrock:dependabot/go_modules/github.com/getsentry/sentry-go-0.43.0
pokebedrock:dependabot/go_modules/github.com/gin-gonic/gin-1.12.0
pokebedrock:dependabot/go_modules/github.com/getsentry/sentry-go-0.42.0
pokebedrock:dependabot/go_modules/github.com/sandertv/gophertunnel-1.53.0
pokebedrock:dependabot/go_modules/github.com/getsentry/sentry-go-0.41.0
pokebedrock:dependabot/go_modules/golang.org/x/text-0.33.0
pokebedrock:dependabot/go_modules/github.com/sandertv/go-raknet-1.15.0
pokebedrock:dependabot/go_modules/golang.org/x/text-0.32.0
pokebedrock:dependabot/go_modules/go_modules-15eab1e1d8
pokebedrock:feature/parkour
pokebedrock:dependabot/go_modules/go_modules-dd7da38a6b
pokebedrock:dependabot/go_modules/github.com/getsentry/sentry-go-0.40.0
pokebedrock:dependabot/go_modules/github.com/getsentry/sentry-go-0.38.0
pokebedrock:dependabot/go_modules/golang.org/x/text-0.31.0
pokebedrock:dependabot/go_modules/github.com/sandertv/gophertunnel-1.51.0
pokebedrock:dependabot/go_modules/github.com/df-mc/dragonfly-0.10.9
pokebedrock:dependabot/go_modules/github.com/getsentry/sentry-go-0.36.2
pokebedrock:dependabot/go_modules/github.com/getsentry/sentry-go-0.36.1
pokebedrock:dependabot/go_modules/github.com/getsentry/sentry-go-0.36.0
pokebedrock:dependabot/go_modules/github.com/samber/lo-1.52.0
pokebedrock:dependabot/go_modules/golang.org/x/text-0.30.0
pokebedrock:dependabot/go_modules/github.com/sandertv/gophertunnel-1.50.1
pokebedrock:dependabot/go_modules/github.com/df-mc/dragonfly-0.10.8
pokebedrock:dependabot/go_modules/github.com/restartfu/gophig-0.1.0
pokebedrock:dependabot/go_modules/github.com/sandertv/gophertunnel-1.50.0
pokebedrock:dependabot/go_modules/github.com/df-mc/dragonfly-0.10.6
pokebedrock:dependabot/go_modules/github.com/sandertv/gophertunnel-1.49.1
pokebedrock:dependabot/go_modules/github.com/gin-gonic/gin-1.11.0
pokebedrock:dependabot/go_modules/github.com/getsentry/sentry-go-0.35.3
pokebedrock:dependabot/go_modules/github.com/getsentry/sentry-go-0.35.2
pokebedrock:dependabot/go_modules/golang.org/x/text-0.29.0
pokebedrock:cursor/fix-linting-errors-and-improve-code-quality-c53d
pokebedrock:cursor/resolve-magic-number-linter-errors-ae43
pokebedrock:dependabot/go_modules/github.com/getsentry/sentry-go-0.35.1
pokebedrock:dependabot/go_modules/golang.org/x/text-0.28.0
pokebedrock:dependabot/go_modules/github.com/getsentry/sentry-go-0.35.0
pokebedrock:dependabot/go_modules/go_modules-985326579b
pokebedrock:dependabot/go_modules/golang.org/x/text-0.27.0
pokebedrock:dependabot/go_modules/github.com/getsentry/sentry-go-0.34.1
pokebedrock:dependabot/go_modules/github.com/go-jose/go-jose/v4-4.1.1
pokebedrock:dependabot/go_modules/go_modules-1bf47a65e7
pokebedrock:support/gobds
pokebedrock:dependabot/go_modules/github.com/df-mc/dragonfly-0.10.5
pokebedrock:dependabot/go_modules/github.com/getsentry/sentry-go-0.34.0
pokebedrock:dependabot/go_modules/golang.org/x/text-0.26.0
pokebedrock:feature/gobds-support
pokebedrock:dependabot/go_modules/golang.org/x/text-0.25.0
pokebedrock:dependabot/go_modules/go_modules-bbb8b02913
pokebedrock:dependabot/go_modules/golang.org/x/text-0.24.0
pokebedrock:dependabot/go_modules/go_modules-c153b83258
pokebedrock:dependabot/go_modules/golang.org/x/text-0.23.0
pokebedrock:alert-autofix-1
pokebedrock:dependabot/go_modules/github.com/df-mc/dragonfly-0.10.2
pokebedrock:dependabot/go_modules/go_modules-6be307652c
No reviewers
Labels
Clear labels
blocked
automation label
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
github_actions
Pull requests that update GitHub Actions code
go
Pull requests that update Go code
good first issue
Good for newcomers
help wanted
Extra attention is needed
in-progress
automation label
invalid
This doesn't seem right
question
Further information is requested
ready-to-fix
automation label
source:discord
automation label
source:sentry
automation label
source:server-logs
automation label
triage-needed
automation label
wontfix
This will not be worked on
No labels
blocked
bug
dependencies
documentation
duplicate
enhancement
github_actions
go
good first issue
help wanted
in-progress
invalid
question
ready-to-fix
source:discord
source:sentry
source:server-logs
triage-needed
wontfix
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set.
Reference
pokebedrock/pokebedrock-hub!105
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/HUB-2-heap-profile-attachment"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Do not merge without Curry's OK.
Stacked on #104 (base is
fix/HUB-3-watchdog-sustained-breach). Merge #104 first, then retarget this tomain. Or fold it into #104 if Curry wants a single release and restart.Sentry: POKEBEDROCK-HUB-2 (
watchdog: heap usage high). One event showed 27.7 GB HeapAlloc against the 2 GiB threshold, with only 285 goroutines. That's real heap growth, not a goroutine pile-up, but the alert carries nothing that says what holds the memory.Change
heap_pressurealerts, attachheap.pprof: the runtime's sampled heap profile, in gzipped pprof format (go tool pprof heap.pprof). It's capped at 8 MiB. A larger profile is dropped rather than cut, since a truncated pprof can't be parsed, and the event getsheap_profile_truncated=true.heap_inuse_bytes,heap_objectsandsys_bytesto thewatchdogcontext for every alert.Cost: a sampled profile, not a full heap dump. A few ms, and only on a heap alert, which is subject to the 5m cooldown.
Tests
go vet ./...,go test ./..., andgo test -race ./pokebedrock/watchdog/...pass. NewTestHeapProfile: the profile is non-empty, gzip, and within the limit, and an over-limit profile is rejected.This repo has no PR CI; release.yml runs vet+test on main. It goes live only after merge and a hub restart, both of which need Curry's OK.
Verdict: no blockers. Merge after #104 (or fold it in), with Curry's OK. Posted as COMMENT because the PR is bot-authored.
Checked locally at
5c5a5eb1since there's no PR CI:go vet,go test -race ./pokebedrock/watchdog/(includingTestHeapProfile) andgo build ./...pass. Using the sampled heap profile (WriteTo(…, 0)) rather than a full dump is the right call, and dropping the profile instead of cutting it is correct, because a truncated pprof file won't parse.Notes:
heap_profile_truncated=truecan be a false label. It's set wheneverheapProfilereturns false, and that also coverspprof.Lookupreturning nil, aWriteToerror, and an empty buffer. Someone triaging will read "too big" when the write actually failed. Use something likeheap_profile: "ok" | "over_limit" | "write_failed" | "empty", or only settruncatedon the size branch (inline).sentry.Flush(2 * time.Second). A heap alert can now carry up to 8 MiB of pprof, and up to 1 MiB more ofgoroutines.txtwhen it fires alongside a stall or pileup. At 27 GB heap the box is usually close to the OOM-kill that the eager flush is there for, and 2s may not get 9 MiB to self-hosted Sentry. Either give the flush more time on heap alerts, or check what the 8 MiB cap is based on: sampled heap profiles are normally tens to hundreds of KB, so 1–2 MiB would still be generous. (The flush line is unchanged context, so this is a body note.)fix/HUB-3-watchdog-sustained-breach. Retarget tomainright after #104 merges, or Forgejo will merge it into a dead branch.TestHeapProfileonly checks gzip magic and size. Aprofile.Parseround-trip would prove it's actually readable bygo tool pprof, but it's optional.@ -393,0 +419,4 @@Payload: prof,})} else {ctx["heap_profile_truncated"] = trueThis also fires when
pprof.Lookupis nil,WriteToerrors, or the buffer is empty, so 'truncated' can be a false label. Use a status value (ok/over_limit/write_failed/empty), or set this only on the size branch.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.