summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2012-10-11 15:20:54 -0400
committerMathias Stearn <mathias@10gen.com>2012-11-05 13:03:03 -0500
commitd5390644810ab9a79146b62a02e46f2854cc340b (patch)
tree43a4c85226550bcfb92b9eb147d67d9c20df35c2 /src/mongo
parentbb98b9b6795889c6e3369dd54341aba3503c5863 (diff)
downloadmongo-d5390644810ab9a79146b62a02e46f2854cc340b.tar.gz
SERVER-7335 Warn if readahead is set to > 256KB
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/db.cpp42
-rw-r--r--src/mongo/util/log.h2
-rw-r--r--src/mongo/util/version.cpp2
3 files changed, 44 insertions, 2 deletions
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp
index a48c26e2c10..32eacdbae22 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -505,6 +505,45 @@ namespace mongo {
return cc().curop()->opNum();
}
+ /// 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";
+ }
+
+ 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"
+ << startupWarningsLog;
+
+ log() << "** We suggest setting it to 256KB (512 sectors) or less"
+ << startupWarningsLog;
+
+ log() << "** http://www.mongodb.org/display/DOCS/Readahead"
+ << startupWarningsLog;
+ }
+ }
+ }
+#endif // __linux__
+ }
+
void _initAndListen(int listenPort ) {
Client::initThread("initandlisten");
@@ -550,6 +589,9 @@ namespace mongo {
uassert( 12590 , ss.str().c_str(), boost::filesystem::exists( repairpath ) );
}
+ // TODO check non-journal subdirs if using directory-per-db
+ checkReadAhead(dbpath);
+
acquirePathLock(forceRepair);
boost::filesystem::remove_all( dbpath + "/_tmp/" );
diff --git a/src/mongo/util/log.h b/src/mongo/util/log.h
index b24b079f151..8e9c52eca68 100644
--- a/src/mongo/util/log.h
+++ b/src/mongo/util/log.h
@@ -439,7 +439,7 @@ namespace mongo {
};
extern Tee* const warnings; // Things put here go in serverStatus
- extern Tee* startupWarningsLog;
+ extern Tee* const startupWarningsLog; // Things put here get reported in MMS
string errnoWithDescription(int errorcode = -1);
void rawOut( const string &s );
diff --git a/src/mongo/util/version.cpp b/src/mongo/util/version.cpp
index 305592b48b9..3f2fa8309ba 100644
--- a/src/mongo/util/version.cpp
+++ b/src/mongo/util/version.cpp
@@ -122,7 +122,7 @@ namespace mongo {
}
- Tee * startupWarningsLog = new RamLog("startupWarnings"); //intentionally leaked
+ Tee* const startupWarningsLog = new RamLog("startupWarnings"); //intentionally leaked
//
// system warnings