Details
Description
When the mongod process can't write to the pid file the following message may appear:
ERROR: Cannot write pid file to /var/run/mongodb/mongod.pid: Success
|
In mongo/util/processinfo.cpp we have:
class PidFileWiper { |
public: |
~PidFileWiper() {
|
if (path.empty()) { |
return; |
}
|
|
|
ofstream out(path.c_str(), ios_base::out);
|
out.close();
|
}
|
|
|
bool write(const string& p) { |
path = p;
|
ofstream out(path.c_str(), ios_base::out);
|
out << ProcessId::getCurrent() << endl;
|
return out.good(); |
}
|
|
|
string path;
|
} pidFileWiper;
|
|
|
bool writePidFile(const string& path) { |
bool e = pidFileWiper.write(path); |
if (!e) { |
log() << "ERROR: Cannot write pid file to " << path << ": " << strerror(errno); |
}
|
return e; |
}
|
The errno value is not reliable with C++ iostreams.
Observed in MongoDB 3.0.5; see SERVER-22072 for more details.
Attachments
Issue Links
- related to
-
SERVER-22072 Unable to start service with error " ERROR: Cannot write pid file to /var/run/mongodb/mongod.pid: Success"
-
- Closed
-