diff options
author | Tad Marshall <tad@10gen.com> | 2012-10-17 05:11:52 -0400 |
---|---|---|
committer | Tad Marshall <tad@10gen.com> | 2012-10-23 14:10:11 -0400 |
commit | 5352345eda2ffa24a72af1d5bbaccaa32bcb1006 (patch) | |
tree | 4ce472071f0eb73b6e29c246eb8993be91aac49f /src/mongo | |
parent | 32a6fdc5f4cb346733a9e2ea31af28f4da73a25b (diff) | |
download | mongo-5352345eda2ffa24a72af1d5bbaccaa32bcb1006.tar.gz |
SERVER-7378 Prevent WRITETODATAFILES and FlushViewOfFile from running at the same time
Prevent errors on Azure Storage drives that occur when a memory-mapped
data file is modified in memory while it is being flushed to disk with
FlushViewOfFile. Use a SimpleMutex (Critical Section on Windows) to
prevent these two routines from running at the same time.
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/dur_writetodatafiles.cpp | 16 | ||||
-rw-r--r-- | src/mongo/util/mmap_win.cpp | 4 |
2 files changed, 16 insertions, 4 deletions
diff --git a/src/mongo/db/dur_writetodatafiles.cpp b/src/mongo/db/dur_writetodatafiles.cpp index a8cda0e6506..f6978920e14 100644 --- a/src/mongo/db/dur_writetodatafiles.cpp +++ b/src/mongo/db/dur_writetodatafiles.cpp @@ -17,12 +17,17 @@ */ #include "pch.h" -#include "dur_commitjob.h" -#include "dur_stats.h" -#include "dur_recover.h" -#include "../util/timer.h" + +#include "mongo/db/dur_commitjob.h" +#include "mongo/db/dur_recover.h" +#include "mongo/db/dur_stats.h" +#include "mongo/util/concurrency/mutex.h" +#include "mongo/util/timer.h" namespace mongo { +#ifdef _WIN32 + extern SimpleMutex globalFlushMutex; // defined in mongo/util/mmap_win.cpp +#endif namespace dur { void debugValidateAllMapsMatch(); @@ -82,6 +87,9 @@ namespace mongo { */ void WRITETODATAFILES(const JSectHeader& h, AlignedBuilder& uncompressed) { +#ifdef _WIN32 + SimpleMutex::scoped_lock _globalFlushMutex(globalFlushMutex); +#endif Timer t; WRITETODATAFILES_Impl1(h, uncompressed); unsigned long long m = t.micros(); diff --git a/src/mongo/util/mmap_win.cpp b/src/mongo/util/mmap_win.cpp index 50936f637de..27a0911cc54 100644 --- a/src/mongo/util/mmap_win.cpp +++ b/src/mongo/util/mmap_win.cpp @@ -326,6 +326,9 @@ namespace mongo { return newPrivateView; } + // prevent WRITETODATAFILES() from running at the same time as FlushViewOfFile() + SimpleMutex globalFlushMutex("globalFlushMutex"); + class WindowsFlushable : public MemoryMappedFile::Flushable { public: WindowsFlushable( void * view, @@ -339,6 +342,7 @@ namespace mongo { if (!_view || !_fd) return; + SimpleMutex::scoped_lock _globalFlushMutex(globalFlushMutex); scoped_lock lk(*_flushMutex); int loopCount = 0; |