Repository navigation
Conversation
The indexer exposed no profiling endpoint and started no HTTP server at all, so diagnosing a production memory and goroutine problem required building a one-off image and rolling it out before any data could be collected. Add a --pprof-bind-address flag, empty by default, which starts a net/http/pprof server when set. Handlers are registered on a dedicated ServeMux rather than by importing the package for its side effects, so http.DefaultServeMux is left untouched. Failures are logged and never fatal: profiling must not be able to take down the indexer. Binding to 127.0.0.1:6060 keeps the endpoint reachable only through kubectl port-forward, which runs inside the pod network namespace, and not from the cluster network. The deployment wires PPROF_BIND_ADDRESS through in the same $(VAR) style as the other flags and defaults it to empty, so this is inert unless deliberately enabled. No containerPort and no Service are added. Refs #113 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XHThCUggHF6zu6wMxHTrN3
ecv
force-pushed
the
feat/indexer-pprof
branch
from
September 9, 2026 21:43
b10300a to
2d0cb07
Compare
Contributor
Author
|
Closing. The incident that prompted it was fixed in #114, and a profiling server can come back if another one needs it. |
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.
Why
Investigating #113 needed a heap and goroutine profile from a production indexer pod. The indexer had no pprof endpoint —
net/http/pprofwas imported nowhere andRun()started no HTTP server of any kind, not even for metrics or health. Getting a single profile therefore meant building a one-off image, pushing it, suspending Flux, patching the deployment, and rolling ten production pods before any data could be collected.That work produced the findings in this comment: goroutines climbing 103 → 4,521 on one pod with 1,114 parked in
meilisearch-go.waitForTask, a heap ~82% under the NATS connection read path, and 29.3% of CPU spent injetstream.Metadata()from thetrackMessageduplicate scan. None of it was reachable without this change.What
Adds
--pprof-bind-address, empty by default. When set, starts anet/http/pprofserver on that address.ServeMux, not by importingnet/http/pproffor its side effects, sohttp.DefaultServeMuxis left untouched.ListenAndServeerrors other thanhttp.ErrServerClosedare logged, never fatal — profiling must not be able to take down the indexer.ReadHeaderTimeoutset to 10s.Validate()rejects a malformed value vianet.SplitHostPort.The deployment passes
--pprof-bind-address=$(PPROF_BIND_ADDRESS)in the same$(VAR)style as every other flag, defaulted to"".Security
Inert unless deliberately enabled. No
containerPortand noServiceare added, deliberately — binding to127.0.0.1:6060keeps the endpoint reachable only throughkubectl port-forward, which runs inside the pod network namespace, and never from the cluster network.Usage
Notes for review
--metrics-bind-addressand its own listener in the same flag block andRun(). The two listeners are independent; whichever merges second needs a small manual merge.internal/indexer/is touched.go build ./...,go vet ./cmd/search/...,gofmt -l, and a smoke test confirming HTTP 200 on/debug/pprof/,heap,goroutineandcmdlineplus clean shutdown on context cancel. It also ran in production for ~45 minutes during the Search stops updating when a delete fan-out outgrows the indexer's memory #113 investigation.Refs #113
🤖 Generated with Claude Code
https://claude.ai/code/session_01XHThCUggHF6zu6wMxHTrN3