Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SERVER-5855 Refuse to run an fsyncLock() command from a locked context.

fsyncLock() inside a locked context deadlocks the server immediately.
  • Loading branch information...
commit e422ec341c86a65348812344f607b3d46d086e75 1 parent bb50025
Andy Schwerin andy10gen authored
Showing with 7 additions and 0 deletions.
  1. +1 −0  jstests/fsync.js
  2. +6 −0 src/mongo/db/commands/fsync.cpp
1  jstests/fsync.js
View
@@ -19,3 +19,4 @@ db.getLastError();
assert( db.currentOp().fsyncLock == null, "A" );
+assert( !db.eval('db.fsyncLock()').ok, "eval('db.fsyncLock()') should fail." )
6 src/mongo/db/commands/fsync.cpp
View
@@ -47,6 +47,12 @@ namespace mongo {
virtual bool adminOnly() const { return true; }
virtual void help(stringstream& h) const { h << url(); }
virtual bool run(const string& dbname, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
+
+ if (Lock::isLocked()) {
+ errmsg = "fsync: Cannot execute fsync command from contexts that hold a data lock";
+ return false;
+ }
+
bool sync = !cmdObj["async"].trueValue(); // async means do an fsync, but return immediately
bool lock = cmdObj["lock"].trueValue();
log() << "CMD fsync: sync:" << sync << " lock:" << lock << endl;
Please sign in to comment.
Something went wrong with that request. Please try again.