summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2018-06-11 17:04:50 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2018-06-11 17:04:50 -0400
commit23dbc49cee99273eeec6910072222d936641f97c (patch)
treef580061c736b1092ba68212d6f5337a401fe00c3 /src/mongo/db
parent666ae1c0efa1f02f3236ff7f49037c3e06b1eb83 (diff)
downloadmongo-23dbc49cee99273eeec6910072222d936641f97c.tar.gz
SERVER-35480 Fix op observer for free monitoring
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/free_mon/free_mon_op_observer.cpp17
-rw-r--r--src/mongo/db/free_mon/free_mon_op_observer.h2
-rw-r--r--src/mongo/db/free_mon/free_mon_processor.cpp10
3 files changed, 26 insertions, 3 deletions
diff --git a/src/mongo/db/free_mon/free_mon_op_observer.cpp b/src/mongo/db/free_mon/free_mon_op_observer.cpp
index b3457a687a6..8dde8c8b53e 100644
--- a/src/mongo/db/free_mon/free_mon_op_observer.cpp
+++ b/src/mongo/db/free_mon/free_mon_op_observer.cpp
@@ -32,6 +32,7 @@
#include "mongo/db/free_mon/free_mon_controller.h"
#include "mongo/db/free_mon/free_mon_storage.h"
+#include "mongo/db/operation_context.h"
namespace mongo {
namespace {
@@ -44,6 +45,8 @@ bool isStandaloneOrPrimary(OperationContext* opCtx) {
repl::MemberState::RS_PRIMARY);
}
+const auto getFreeMonDeleteState = OperationContext::declareDecoration<bool>();
+
} // namespace
FreeMonOpObserver::FreeMonOpObserver() = default;
@@ -111,6 +114,18 @@ void FreeMonOpObserver::onUpdate(OperationContext* opCtx, const OplogUpdateEntry
}
}
+void FreeMonOpObserver::aboutToDelete(OperationContext* opCtx,
+ const NamespaceString& nss,
+ const BSONObj& doc) {
+
+ bool isFreeMonDoc = (nss == NamespaceString::kServerConfigurationNamespace) &&
+ (doc["_id"].str() == FreeMonStorage::kFreeMonDocIdKey);
+
+ // Set a flag that indicates whether the document to be delete is the free monitoring state
+ // document
+ getFreeMonDeleteState(opCtx) = isFreeMonDoc;
+}
+
void FreeMonOpObserver::onDelete(OperationContext* opCtx,
const NamespaceString& nss,
OptionalCollectionUUID uuid,
@@ -125,7 +140,7 @@ void FreeMonOpObserver::onDelete(OperationContext* opCtx,
return;
}
- if (deletedDoc.get()["_id"].str() == FreeMonStorage::kFreeMonDocIdKey) {
+ if (getFreeMonDeleteState(opCtx) == true) {
auto controller = FreeMonController::get(opCtx->getServiceContext());
if (controller != nullptr) {
diff --git a/src/mongo/db/free_mon/free_mon_op_observer.h b/src/mongo/db/free_mon/free_mon_op_observer.h
index c084c440dd2..05d16a21e4a 100644
--- a/src/mongo/db/free_mon/free_mon_op_observer.h
+++ b/src/mongo/db/free_mon/free_mon_op_observer.h
@@ -61,7 +61,7 @@ public:
void aboutToDelete(OperationContext* opCtx,
const NamespaceString& nss,
- const BSONObj& doc) final {}
+ const BSONObj& doc) final;
void onDelete(OperationContext* opCtx,
const NamespaceString& nss,
diff --git a/src/mongo/db/free_mon/free_mon_processor.cpp b/src/mongo/db/free_mon/free_mon_processor.cpp
index c192ab21d93..4ff1411145e 100644
--- a/src/mongo/db/free_mon/free_mon_processor.cpp
+++ b/src/mongo/db/free_mon/free_mon_processor.cpp
@@ -791,6 +791,11 @@ void FreeMonProcessor::doAsyncMetricsComplete(
auto opCtxUnique = client->makeOperationContext();
FreeMonStorage::deleteState(opCtxUnique.get());
+ _state->setState(StorageStateEnum::pending);
+
+ // Clear out the in-memory state
+ _lastReadState = boost::none;
+
return;
}
@@ -945,7 +950,10 @@ void FreeMonProcessor::doNotifyOnDelete(Client* client) {
// the same and stop free monitoring. We continue collecting though.
// So we mark the internal state as disabled which stop registration and metrics send
- _state->setState(StorageStateEnum::disabled);
+ _state->setState(StorageStateEnum::pending);
+
+ // Clear out the in-memory state
+ _lastReadState = boost::none;
}
void FreeMonProcessor::doNotifyOnRollback(Client* client) {