/images/logo.svg

NTOHL

go tool pprof returns an empty debug/pprof/heap profile

Fetching debug/pprof/heap with go tool pprof gave an empty profile.

The reason is that Go samples memory allocations by default once every 512KB (runtime.MemProfileRate defaults to 512 * 1024). If the process doesn’t allocate that much during the window, no samples are taken at all and the profile stays empty.

The fix is to shrink the sampling interval, most easily through the GODEBUG environment variable:

export GODEBUG="memprofilerate=1"

1 means sample on every allocation. That costs real performance, so only turn it on while you’re debugging.

golang pprof returns 404 page not found for debug/pprof

Hitting /debug/pprof/ always returned 404 page not found. The explanation starts with how net/http/pprof registers itself:

func init() {
	http.HandleFunc("/debug/pprof/", Index)
	http.HandleFunc("/debug/pprof/cmdline", Cmdline)
	http.HandleFunc("/debug/pprof/profile", Profile)
	http.HandleFunc("/debug/pprof/symbol", Symbol)
	http.HandleFunc("/debug/pprof/trace", Trace)
}

Importing _ "net/http/pprof" registers those five routes on http.DefaultServeMux from init. If the service uses its own router (httprouter, in my case), requests never reach DefaultServeMux, the pprof routes are dead weight, and you get a 404.

AXFR and IXFR in DNS

Introduction

AXFR is the DNS Zone Transfer Protocol. In a primary/secondary setup, the secondary asks the primary for the entire zone, and the primary returns every record in a single AXFR response, so the secondary can replace its local copy wholesale.

IXFR is Incremental Zone Transfer. Where AXFR sends the whole zone at once, IXFR sends only the records that changed.

bind9 failing to create jnl: netsh.xyz.zone.jnl: create: permission denied

While testing bind9 replication and the notify / ixfr / axfr machinery, I ran rndc reload zone on the secondary and captured traffic — no notify or ixfr packets at all. The named.run log explained why:

netsh.xyz.zone.jnl: create: permission denied

My first guess was file permissions or SELinux; neither turned out to be the cause. A search led to a thread on centos.org, where the fix is to move the zone files into named’s data directory and reference them with a relative path in named.conf.