-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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(inputs.mongodb): resolve SIGSEGV when restarting MongoDB node #12604
fix(inputs.mongodb): resolve SIGSEGV when restarting MongoDB node #12604
Conversation
ca9271a
to
005d1a8
Compare
Fairly often reproducible but not always. The issue is that the newStat (ServerStatus) doesn't have its Locks populated. This change adds necessary "nil" checks to avoid a "nil pointer dereference" error crashing the telegraf process. The oldStat already has the exact same (symmetric) checks in place.
005d1a8
to
90f1997
Compare
Download PR build artifacts for linux_amd64.tar.gz, darwin_amd64.tar.gz, and windows_amd64.zip. 📦 Click here to get additional PR build artifactsArtifact URLs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR and tests! Is there an issue that is associated with this fix that we can close as well?
Hi @powersj, I haven't found any related issues, neither open nor closed. |
@dkhamitov I took the liberty to open an issue with the information you provided. In the future, please open an issue first describing the problem and then reference this issue in your PR. This is to allow other users with a similar problem to easier discover the solution (your PR) as they might only search in issues... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks @dkhamitov for tracking this down and fixing it!
Got it. Thanks! |
(cherry picked from commit e466cab)
Below is an example of the SIGSEGV I occasionally get when restarting a MongoDB node that is being monitored by Telegraf MongoDB plugin. I think it rather happens during the node shutdown, though. Because according to the stacktrace, it's the
newStat
variable that doesn't haveLocks
populated as the code expects. The proposed fix is quite straightforward. It just adds adds necessarynil
checks that are the same (symmetric) as those performed on theoldStat
data.The stacktrace below is for Telegraf 1.24.2. The line with "nil pointer dereference" can be found at
telegraf/plugins/inputs/mongodb/mongostat.go
Line 1227 in 9550e7a
Also, quite often but not always, I can catch the following error in the plugin before the crash:
Required for all PRs
resolves #12611