Skip to content
New issue

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

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

Already on GitHub? # to your account

fix(inputs.mongodb): Do not dereference nil pointer if gathering database stats fails #16310

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

dkhamitov
Copy link
Contributor

@dkhamitov dkhamitov commented Dec 15, 2024

Summary

Occasionally happens on our clusters, like every 2-4 weeks. The error message has never been seen as it gets logged at Debug level, which has also been changed to Error in this commit. Please let me know if the log level update is not an issue as I can see some errors are only logged at Debug level.

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

goroutine 4494435 [running]:
github.com/influxdata/telegraf/plugins/inputs/mongodb.(*Server).gatherData (0xc000f3c900, {0x6d39940, 0xc000667a80}, 0x0, 0x1, 0x1, 0x1, {0x9ec1ed0, 0x0, 0x0})
        /go/src/github.com/influxdata/telegraf/plugins/inputs/mongodb/mongodb_server.go:338 +0x5f7
github.com/influxdata/telegraf/plugins/inputs/mongodb.(*MongoDB).Gather.func1(0xc000813480?)
        /go/src/github.com/influxdata/telegraf/plugins/inputs/mongodb/mongodb.go:180 +0x1a9
created by github.com/influxdata/telegraf/plugins/inputs/mongodb.(*MongoDB).Gather
        /go/src/github.com/influxdata/telegraf/plugins/inputs/mongodb/mongodb.go:171 +0x65

Checklist

  • No AI generated code was used in this PR

Related issues

Resolves #16329

… pointer for db causing subsequent dereference failure

Occasionally happens on our clusters, like every 2-4 weeks. The error message has never been seen as it gets logged at Debug level, which has also been changed to Error in this commit.
@telegraf-tiger telegraf-tiger bot added area/mongodb fix pr to fix corresponding bug plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels Dec 15, 2024
@srebhan
Copy link
Member

srebhan commented Dec 17, 2024

@dkhamitov could you please open an issue additional to this PR describing the issue? This will ease finding this solution for other users...

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your fix @dkhamitov! I do have one small comment in the code...

@srebhan srebhan changed the title fix(inputs.mongodb): SIGSEGV when gatherDBStats fails and returns nil pointer causing subsequent dereference failure fix(inputs.mongodb): Do not dereference nil pointer if gathering database stats fails Dec 17, 2024
@srebhan srebhan self-assigned this Dec 17, 2024
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
@telegraf-tiger
Copy link
Contributor

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dkhamitov!

@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Dec 17, 2024
@srebhan srebhan assigned DStrand1 and unassigned srebhan Dec 17, 2024
@DStrand1 DStrand1 merged commit 3b87986 into influxdata:master Dec 17, 2024
27 checks passed
@github-actions github-actions bot added this to the v1.33.1 milestone Dec 17, 2024
justinwwhuang pushed a commit to justinwwhuang/telegraf_fork that referenced this pull request Dec 19, 2024
izekr pushed a commit to izekr/telegraf that referenced this pull request Dec 19, 2024
@dkhamitov dkhamitov deleted the fix/mongodb-sigsegv-dbstats branch December 20, 2024 17:15
DStrand1 pushed a commit that referenced this pull request Jan 10, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
area/mongodb fix pr to fix corresponding bug plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Occasional Panic/SIGSEGV from mongodb plugin when gathering database stats
3 participants