summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Hernandez <scotthernandez@gmail.com>2016-02-11 09:31:42 -0500
committerScott Hernandez <scotthernandez@tart.local>2016-02-24 09:55:46 -0500
commit55f46c6c978099140975c26f6a06518dadbf5784 (patch)
tree7b43749c84b15ff1f742380ff1bc98aa52361b57 /src
parent8178d632b5d446d2c19342cb0de4630d3224b12d (diff)
downloadmongo-55f46c6c978099140975c26f6a06518dadbf5784.tar.gz
SERVER-22534: mark each ephemeralForTesting write as journaled for replication
(cherry picked from commit 6c43579b859105f4b3d72d60e644dd35dff58714)
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/storage/ephemeral_for_test/SConscript3
-rw-r--r--src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.cpp7
-rw-r--r--src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.h9
-rw-r--r--src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.cpp5
-rw-r--r--src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.h8
5 files changed, 30 insertions, 2 deletions
diff --git a/src/mongo/db/storage/ephemeral_for_test/SConscript b/src/mongo/db/storage/ephemeral_for_test/SConscript
index 0b4c4729200..c8faa524429 100644
--- a/src/mongo/db/storage/ephemeral_for_test/SConscript
+++ b/src/mongo/db/storage/ephemeral_for_test/SConscript
@@ -66,6 +66,9 @@ env.CppUnitTest(
source=['ephemeral_for_test_engine_test.cpp',
],
LIBDEPS=[
+ '$BUILD_DIR/mongo/db/storage/journal_listener',
+ '$BUILD_DIR/mongo/db/storage/kv/kv_engine_test_harness',
+ '$BUILD_DIR/mongo/db/storage/storage_options',
'storage_ephemeral_for_test_core',
'$BUILD_DIR/mongo/db/storage/kv/kv_engine_test_harness',
],
diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.cpp
index 6f0cd2cbaae..ea11eb90f46 100644
--- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.cpp
+++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.cpp
@@ -34,11 +34,16 @@
#include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_btree_impl.h"
#include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store.h"
#include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.h"
+#include "mongo/db/storage/journal_listener.h"
namespace mongo {
RecoveryUnit* EphemeralForTestEngine::newRecoveryUnit() {
- return new EphemeralForTestRecoveryUnit();
+ return new EphemeralForTestRecoveryUnit([this]() {
+ stdx::lock_guard<stdx::mutex> lk(_mutex);
+ JournalListener::Token token = _journalListener->getToken();
+ _journalListener->onDurable(token);
+ });
}
Status EphemeralForTestEngine::createRecordStore(OperationContext* opCtx,
diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.h b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.h
index 01e322f60bb..0c19b040c73 100644
--- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.h
+++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_engine.h
@@ -30,6 +30,7 @@
#pragma once
+#include "mongo/db/storage/journal_listener.h"
#include "mongo/db/storage/kv/kv_engine.h"
#include "mongo/stdx/mutex.h"
#include "mongo/util/string_map.h"
@@ -98,12 +99,18 @@ public:
std::vector<std::string> getAllIdents(OperationContext* opCtx) const;
- void setJournalListener(JournalListener* jl) final {}
+ void setJournalListener(JournalListener* jl) final {
+ stdx::unique_lock<stdx::mutex> lk(_mutex);
+ _journalListener = jl;
+ }
private:
typedef StringMap<std::shared_ptr<void>> DataMap;
mutable stdx::mutex _mutex;
DataMap _dataMap; // All actual data is owned in here
+
+ // Notified when we write as everything is considered "journalled" since repl depends on it.
+ JournalListener* _journalListener = &NoOpJournalListener::instance;
};
}
diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.cpp
index 016f66cdb1e..ef80739cd31 100644
--- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.cpp
+++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.cpp
@@ -46,6 +46,11 @@ void EphemeralForTestRecoveryUnit::commitUnitOfWork() {
} catch (...) {
std::terminate();
}
+
+ // This ensures that the journal listener gets called on each commit.
+ // SERVER-22575: Remove this once we add a generic mechanism to periodically wait
+ // for durability.
+ waitUntilDurable();
}
void EphemeralForTestRecoveryUnit::abortUnitOfWork() {
diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.h b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.h
index 96133ab3e57..4b7925248e4 100644
--- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.h
+++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.h
@@ -34,6 +34,7 @@
#include "mongo/db/record_id.h"
#include "mongo/db/storage/recovery_unit.h"
+#include "mongo/stdx/functional.h"
namespace mongo {
@@ -41,11 +42,17 @@ class SortedDataInterface;
class EphemeralForTestRecoveryUnit : public RecoveryUnit {
public:
+ EphemeralForTestRecoveryUnit(stdx::function<void()> cb = nullptr)
+ : _waitUntilDurableCallback(cb) {}
+
void beginUnitOfWork(OperationContext* opCtx) final{};
void commitUnitOfWork() final;
void abortUnitOfWork() final;
virtual bool waitUntilDurable() {
+ if (_waitUntilDurableCallback) {
+ _waitUntilDurableCallback();
+ }
return true;
}
@@ -70,6 +77,7 @@ private:
typedef std::vector<ChangePtr> Changes;
Changes _changes;
+ stdx::function<void()> _waitUntilDurableCallback;
};
} // namespace mongo