summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLingzhi Deng <lingzhi.deng@mongodb.com>2019-07-16 11:52:26 -0400
committerLingzhi Deng <lingzhi.deng@mongodb.com>2019-07-16 11:52:26 -0400
commit4d9046298c4f7ddaeceebfbab9080527715624e3 (patch)
treeea143faaff744273b50ca26383edb4fb602e3bd5 /src
parent0ca0e5af03ebecefeec44de3ce6870a4f55fa755 (diff)
downloadmongo-4d9046298c4f7ddaeceebfbab9080527715624e3.tar.gz
syncNow
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/commands/fail_point_cmd.cpp6
-rw-r--r--src/mongo/util/fail_point.cpp17
-rw-r--r--src/mongo/util/fail_point_service.cpp16
-rw-r--r--src/mongo/util/fail_point_service.h5
4 files changed, 43 insertions, 1 deletions
diff --git a/src/mongo/db/commands/fail_point_cmd.cpp b/src/mongo/db/commands/fail_point_cmd.cpp
index 52ffb278a22..408a5857470 100644
--- a/src/mongo/db/commands/fail_point_cmd.cpp
+++ b/src/mongo/db/commands/fail_point_cmd.cpp
@@ -97,7 +97,11 @@ public:
const BSONObj& cmdObj,
BSONObjBuilder& result) override {
const std::string failPointName(cmdObj.firstElement().str());
- setGlobalFailPoint(failPointName, cmdObj);
+
+ if (failPointName == "now" && cmdObj.hasField("sync"))
+ syncNow(cmdObj);
+ else
+ setGlobalFailPoint(failPointName, cmdObj);
return true;
}
diff --git a/src/mongo/util/fail_point.cpp b/src/mongo/util/fail_point.cpp
index 7761f3a697a..e51d6e22756 100644
--- a/src/mongo/util/fail_point.cpp
+++ b/src/mongo/util/fail_point.cpp
@@ -351,6 +351,23 @@ BSONObj FailPoint::toBSON() const {
builder.append("mode", _mode);
builder.append("data", _data);
+ BSONObjBuilder syncBuilder;
+ syncBuilder.append("enabled", _syncConfig.enabled);
+ {
+ BSONArrayBuilder signalsArrayBuilder(syncBuilder.subarrayStart("signals"));
+ for (auto& s : _syncConfig.signals) {
+ signalsArrayBuilder.append(s);
+ }
+ }
+ {
+ BSONArrayBuilder waitForArrayBuilder(syncBuilder.subarrayStart("waitFor"));
+ for (auto& w : _syncConfig.waitFor) {
+ waitForArrayBuilder.append(w);
+ }
+ }
+ syncBuilder.append("clearSignals", _syncConfig.clearSignals);
+ builder.append("sync", syncBuilder.obj());
+
return builder.obj();
}
}
diff --git a/src/mongo/util/fail_point_service.cpp b/src/mongo/util/fail_point_service.cpp
index 20b7baf5e5c..f2ceb8bc42f 100644
--- a/src/mongo/util/fail_point_service.cpp
+++ b/src/mongo/util/fail_point_service.cpp
@@ -62,6 +62,22 @@ FailPointRegistry* getGlobalFailPointRegistry() {
return _fpRegistry.get();
}
+void syncNow(const BSONObj& cmdObj) {
+ FailPoint fp;
+
+ FailPoint::Mode mode;
+ FailPoint::ValType val;
+ BSONObj data;
+ FailPoint::SyncConfig syncConfig;
+ std::tie(mode, val, data, syncConfig) = uassertStatusOK(FailPoint::parseBSON(cmdObj));
+
+ fp.setMode(mode, val, data, syncConfig);
+
+ warning() << "failpoint: 'now' set to: " << fp.toBSON();
+ MONGO_FAIL_POINT_SYNC(fp);
+ warning() << "failpoint: 'now' synced";
+}
+
void setGlobalFailPoint(const std::string& failPointName, const BSONObj& cmdObj) {
FailPointRegistry* registry = getGlobalFailPointRegistry();
FailPoint* failPoint = registry->getFailPoint(failPointName);
diff --git a/src/mongo/util/fail_point_service.h b/src/mongo/util/fail_point_service.h
index 64c511942fc..12903ddbcea 100644
--- a/src/mongo/util/fail_point_service.h
+++ b/src/mongo/util/fail_point_service.h
@@ -41,6 +41,11 @@ namespace mongo {
FailPointRegistry* getGlobalFailPointRegistry();
/**
+ * Signals or waits inline.
+ */
+void syncNow(const BSONObj& cmdObj);
+
+/**
* Set a fail point in the global registry to a given value via BSON
* @throw DBException If no failpoint called failPointName exists.
*/