diff options
author | Benety Goh <benety@mongodb.com> | 2015-06-08 16:09:29 -0400 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2015-06-08 19:36:22 -0400 |
commit | d7902c7d026c5656b234319e6cb6152574ecab3f (patch) | |
tree | 44508c68f7d082c8a13f49d95cfbafbe42e1566c /src/mongo/db/storage/storage_engine_lock_file_posix.cpp | |
parent | ac4ee0d1a4ec241f18bc2ac947f13926c221ebcf (diff) | |
download | mongo-d7902c7d026c5656b234319e6cb6152574ecab3f.tar.gz |
SERVER-18876 server should not start up if fsync fails on lock file
Diffstat (limited to 'src/mongo/db/storage/storage_engine_lock_file_posix.cpp')
-rw-r--r-- | src/mongo/db/storage/storage_engine_lock_file_posix.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/mongo/db/storage/storage_engine_lock_file_posix.cpp b/src/mongo/db/storage/storage_engine_lock_file_posix.cpp index 6897f413fbe..f7f12871053 100644 --- a/src/mongo/db/storage/storage_engine_lock_file_posix.cpp +++ b/src/mongo/db/storage/storage_engine_lock_file_posix.cpp @@ -140,7 +140,8 @@ namespace { if (::ftruncate(_lockFileHandle->_fd, 0)) { int errorcode = errno; return Status(ErrorCodes::FileStreamFailed, str::stream() - << errnoWithDescription(errorcode)); + << "Unable to write process id to file (ftruncate failed): " + << _filespec << ' ' << errnoWithDescription(errorcode)); } ProcessId pid = ProcessId::getCurrent(); @@ -161,7 +162,13 @@ namespace { << _filespec << " no data written."); } - ::fsync(_lockFileHandle->_fd); + if (::fsync(_lockFileHandle->_fd)) { + int errorcode = errno; + return Status(ErrorCodes::FileStreamFailed, str::stream() + << "Unable to write process id " << pid.toString() << " to file (fsync failed): " + << _filespec << ' ' << errnoWithDescription(errorcode)); + } + flushMyDirectory(_filespec); return Status::OK(); |