Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix nil pointer #33

Merged
merged 1 commit into from
Dec 16, 2022
Merged

fix nil pointer #33

merged 1 commit into from
Dec 16, 2022

Conversation

hzhao-wish
Copy link

@hzhao-wish hzhao-wish commented Dec 16, 2022

Log shows that metricsReplApplyOpsTotal.Set(applyStats.Ops) throws nil pointer error.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x7a99cb]

goroutine 46 [running]:
github.com/dcu/mongodb_exporter/collector.(*ApplyStats).Export(0x0, 0xc000180420?)
	/go/src/github.com/dcu/mongodb_exporter/collector/metrics.go:315 +0x2b
github.com/dcu/mongodb_exporter/collector.(*ReplStats).Export(0xc000132320, 0x881711?)
	/go/src/github.com/dcu/mongodb_exporter/collector/metrics.go:363 +0x29
github.com/dcu/mongodb_exporter/collector.(*MetricsStats).Export(0xc0002a0140, 0xc0000fec40?)
	/go/src/github.com/dcu/mongodb_exporter/collector/metrics.go:479 +0xd9
github.com/dcu/mongodb_exporter/collector.(*ServerStatus).Export(0xc0000a3110, 0x1?)
	/go/src/github.com/dcu/mongodb_exporter/collector/server_status.go:125 +0x285
github.com/dcu/mongodb_exporter/collector.(*MongodbCollector).collectServerStatus(0xc0001af680?, 0x0?, 0x0?)
	/go/src/github.com/dcu/mongodb_exporter/collector/mongodb_collector.go:173 +0x85
github.com/dcu/mongodb_exporter/collector.(*MongodbCollector).Collect(0xc0001a4090, 0x0?)
	/go/src/github.com/dcu/mongodb_exporter/collector/mongodb_collector.go:107 +0x348
github.com/prometheus/client_golang/prometheus.(*Registry).Gather.func2({0x9370b8?, 0xc0001a4090?})
	/go/src/github.com/dcu/mongodb_exporter/vendor/github.com/prometheus/client_golang/prometheus/registry.go:433 +0x6d
created by github.com/prometheus/client_golang/prometheus.(*Registry).Gather
	/go/src/github.com/dcu/mongodb_exporter/vendor/github.com/prometheus/client_golang/prometheus/registry.go:431 +0x2d0

Check nil before calling set function. Hard to set up a mongoproxy in dev (cannot configure vault, git-sync, ...). Plan to test in toolsstage cluster.

@hzhao-wish hzhao-wish merged commit 9cf110a into master Dec 16, 2022
@hzhao-wish hzhao-wish deleted the fix_applyStats_nil_pointer branch December 16, 2022 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants