summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Pasette <dan@10mongodb.com>2014-03-08 16:17:48 -0500
committerDan Pasette <dan@mongodb.com>2014-03-09 11:27:35 -0400
commit989ed9711ec10194476e65813183d9fae290af88 (patch)
tree5545241380446ecd44a2f0d8d3be5eb73603c6f8
parentc7436cd7fc8d2e7d891bcba6cd2d897b98b0fbcf (diff)
downloadmongo-989ed9711ec10194476e65813183d9fae290af88.tar.gz
SERVER-9248 Ignore errors when checking readahead
To test, run sudo chmod o-x /sys/dev/block Manual backport of commit 9501c1bfce47079de54e0aba7b78bae341e3e916
-rw-r--r--src/mongo/db/db.cpp54
1 files changed, 31 insertions, 23 deletions
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp
index b66cd60d913..29d470f39e0 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -543,38 +543,46 @@ namespace mongo {
/// warn if readahead > 256KB (gridfs chunk size)
static void checkReadAhead(const string& dir) {
#ifdef __linux__
- const dev_t dev = getPartition(dir);
-
- // This path handles the case where the filesystem uses the whole device (including LVM)
- string path = str::stream() <<
- "/sys/dev/block/" << major(dev) << ':' << minor(dev) << "/queue/read_ahead_kb";
-
- if (!boost::filesystem::exists(path)){
- // This path handles the case where the filesystem is on a partition.
- path = str::stream()
- << "/sys/dev/block/" << major(dev) << ':' << minor(dev) // this is a symlink
- << "/.." // parent directory of a partition is for the whole device
- << "/queue/read_ahead_kb";
- }
+ try {
+ const dev_t dev = getPartition(dir);
+
+ // This path handles the case where the filesystem uses the whole device (including LVM)
+ string path = str::stream() <<
+ "/sys/dev/block/" << major(dev) << ':' << minor(dev) << "/queue/read_ahead_kb";
+
+ if (!boost::filesystem::exists(path)){
+ // This path handles the case where the filesystem is on a partition.
+ path = str::stream()
+ << "/sys/dev/block/" << major(dev) << ':' << minor(dev) // this is a symlink
+ << "/.." // parent directory of a partition is for the whole device
+ << "/queue/read_ahead_kb";
+ }
- if (boost::filesystem::exists(path)) {
- ifstream file (path.c_str());
- if (file.is_open()) {
- int kb;
- file >> kb;
- if (kb > 256) {
- log() << startupWarningsLog;
+ if (boost::filesystem::exists(path)) {
+ ifstream file (path.c_str());
+ if (file.is_open()) {
+ int kb;
+ file >> kb;
+ if (kb > 256) {
+ log() << startupWarningsLog;
- log() << "** WARNING: Readahead for " << dir << " is set to " << kb << "KB"
+ log() << "** WARNING: Readahead for " << dir << " is set to " << kb << "KB"
<< startupWarningsLog;
- log() << "** We suggest setting it to 256KB (512 sectors) or less"
+ log() << "** We suggest setting it to 256KB (512 sectors) or less"
<< startupWarningsLog;
- log() << "** http://dochub.mongodb.org/core/readahead"
+ log() << "** http://dochub.mongodb.org/core/readahead"
<< startupWarningsLog;
+ }
}
}
+ catch (const std::exception& e) {
+ log() << "unable to validate readahead settings due to error: " << e.what()
+ << startupWarningsLog;
+ log() << "for more information, see http://dochub.mongodb.org/core/readahead"
+ << startupWarningsLog;
+ }
}
#endif // __linux__
}