Skip to content

Instantly share code, notes, and snippets.

@aw
Created March 30, 2017 06:42
Show Gist options
  • Save aw/8dab36b24ff99bf9ec6357893190fa9b to your computer and use it in GitHub Desktop.
Save aw/8dab36b24ff99bf9ec6357893190fa9b to your computer and use it in GitHub Desktop.
[SOLUTION] MongoDB aborting after invariant() failure

I recently ran into an issue of MongoDB shell commands not working. The error message was:

Invariant failure !driverName.empty() && !driverVersion.empty() && !osType.empty() && !osName.empty() && !osArchitecture.empty() && !osVersion.empty() src/mongo/rpc/metadata/client_metadata.cpp

I ran an strace on the mongo command and saw it was trying (and failing) to open the following files:

stat("/etc/lsb-release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/system-release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/redhat-release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/gentoo-release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/novell-release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/gentoo-release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/SuSE-release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/SUSE-release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/sles-release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/debian_release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/slackware-version", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/centos-release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)
stat("/etc/os-release", 0x7fff38e42a80) = -1 ENOENT (No such file or directory)

SOLUTION

I solved this by simply creating a string in the /etc/system-release file:

echo "My OS version 1.2.3" > /etc/system-release

Hopefully this helps someone else having the same issue.

strace is your friend.

@rsdmike
Copy link

rsdmike commented Sep 11, 2017

Great! Thanks! Helped me out!

@aw
Copy link
Author

aw commented Sep 27, 2017

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment