summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeert Bosch <geert@mongodb.com>2017-12-13 14:03:42 -0500
committerGeert Bosch <geert@mongodb.com>2018-01-03 18:50:43 -0500
commit42a8f21be68549c31cbe80b6f15faff6d4eb6eda (patch)
tree5fc3d178147649ba421b8ede3147de2475e1f9e7
parent201fb860e1ba6dd43e12f0dd30d7af31852a3796 (diff)
downloadmongo-42a8f21be68549c31cbe80b6f15faff6d4eb6eda.tar.gz
SERVER-32315 Remove IndexObserver
(cherry picked from commit 715cedf3377220a5c5e774b2ad5034996336f36f)
-rw-r--r--src/mongo/db/catalog/SConscript1
-rw-r--r--src/mongo/db/catalog/collection.h14
-rw-r--r--src/mongo/db/catalog/collection_impl.cpp30
-rw-r--r--src/mongo/db/catalog/collection_impl.h22
-rw-r--r--src/mongo/db/catalog/collection_mock.h7
-rw-r--r--src/mongo/db/catalog/index_observer.cpp59
-rw-r--r--src/mongo/db/catalog/index_observer.h60
-rw-r--r--src/mongo/db/index/index_access_method.cpp21
8 files changed, 0 insertions, 214 deletions
diff --git a/src/mongo/db/catalog/SConscript b/src/mongo/db/catalog/SConscript
index e5e3f3a00a1..fc1b39ab35c 100644
--- a/src/mongo/db/catalog/SConscript
+++ b/src/mongo/db/catalog/SConscript
@@ -231,7 +231,6 @@ env.Library(
"index_catalog_entry_impl.cpp",
"index_consistency.cpp",
"index_create_impl.cpp",
- "index_observer.cpp",
"private/record_store_validate_adaptor.cpp",
],
LIBDEPS=[
diff --git a/src/mongo/db/catalog/collection.h b/src/mongo/db/catalog/collection.h
index 1e9ad8ff4cd..1426251fd28 100644
--- a/src/mongo/db/catalog/collection.h
+++ b/src/mongo/db/catalog/collection.h
@@ -324,11 +324,6 @@ public:
virtual void notifyCappedWaitersIfNeeded() = 0;
virtual const CollatorInterface* getDefaultCollator() const = 0;
-
- virtual void informIndexObserver(OperationContext* opCtx,
- const IndexDescriptor* descriptor,
- const IndexKeyEntry& indexEntry,
- const ValidationOperation operation) const = 0;
};
private:
@@ -733,15 +728,6 @@ public:
return this->_impl().getDefaultCollator();
}
- /**
- * Calls the Inforn function in the IndexObserver if it's hooked.
- */
- inline void informIndexObserver(OperationContext* opCtx,
- const IndexDescriptor* descriptor,
- const IndexKeyEntry& indexEntry,
- const ValidationOperation operation) const {
- return this->_impl().informIndexObserver(opCtx, descriptor, indexEntry, operation);
- }
private:
inline DatabaseCatalogEntry* dbce() const {
diff --git a/src/mongo/db/catalog/collection_impl.cpp b/src/mongo/db/catalog/collection_impl.cpp
index f88d8502cc9..94e8e232620 100644
--- a/src/mongo/db/catalog/collection_impl.cpp
+++ b/src/mongo/db/catalog/collection_impl.cpp
@@ -46,7 +46,6 @@
#include "mongo/db/catalog/document_validation.h"
#include "mongo/db/catalog/index_consistency.h"
#include "mongo/db/catalog/index_create.h"
-#include "mongo/db/catalog/index_observer.h"
#include "mongo/db/catalog/namespace_uuid_cache.h"
#include "mongo/db/catalog/uuid_catalog.h"
#include "mongo/db/clientcursor.h"
@@ -1032,35 +1031,6 @@ const CollatorInterface* CollectionImpl::getDefaultCollator() const {
return _collator.get();
}
-void CollectionImpl::informIndexObserver(OperationContext* opCtx,
- const IndexDescriptor* descriptor,
- const IndexKeyEntry& indexEntry,
- const ValidationOperation operation) const {
- // The index observer was used for a project that would allow concurrent validation of
- // collection/index consistency while updates were happening to the collection. That project did
- // not make it in for 3.6. This mutex is in a hot code path, so we're going to avoid locking it
- // for the time being. See SERVER-31948.
- const bool unusedReturnEarlyForPerf = true;
- if (unusedReturnEarlyForPerf) {
- return;
- }
-
- stdx::lock_guard<stdx::mutex> lock(_indexObserverMutex);
- if (_indexObserver) {
- _indexObserver->inform(opCtx, descriptor, std::move(indexEntry), operation);
- }
-}
-
-void CollectionImpl::hookIndexObserver(IndexConsistency* consistency) {
- stdx::lock_guard<stdx::mutex> lock(_indexObserverMutex);
- _indexObserver = stdx::make_unique<IndexObserver>(consistency);
-}
-
-void CollectionImpl::unhookIndexObserver() {
- stdx::lock_guard<stdx::mutex> lock(_indexObserverMutex);
- _indexObserver.reset();
-}
-
namespace {
using ValidateResultsMap = std::map<std::string, ValidateResults>;
diff --git a/src/mongo/db/catalog/collection_impl.h b/src/mongo/db/catalog/collection_impl.h
index dc551cc8fd5..ea74bbf6419 100644
--- a/src/mongo/db/catalog/collection_impl.h
+++ b/src/mongo/db/catalog/collection_impl.h
@@ -36,7 +36,6 @@
namespace mongo {
class IndexConsistency;
-class IndexObserver;
class UUIDCatalog;
class CollectionImpl final : virtual public Collection::Impl,
virtual CappedCallback,
@@ -371,15 +370,6 @@ public:
*/
const CollatorInterface* getDefaultCollator() const final;
- /**
- * Calls the Inform function in the IndexObserver if it's hooked.
- */
- void informIndexObserver(OperationContext* opCtx,
- const IndexDescriptor* descriptor,
- const IndexKeyEntry& indexEntry,
- const ValidationOperation operation) const;
-
-
private:
inline DatabaseCatalogEntry* dbce() const final {
return this->_dbce;
@@ -390,16 +380,6 @@ private:
}
/**
- * Hooks the IndexObserver into the collection.
- */
- void hookIndexObserver(IndexConsistency* consistency);
-
- /**
- * Unhooks the IndexObserver from the collection.
- */
- void unhookIndexObserver();
-
- /**
* Returns a non-ok Status if document does not pass this collection's validator.
*/
Status checkValidation(OperationContext* opCtx, const BSONObj& document) const;
@@ -447,8 +427,6 @@ private:
CollectionInfoCache _infoCache;
IndexCatalog _indexCatalog;
- mutable stdx::mutex _indexObserverMutex;
- mutable std::unique_ptr<IndexObserver> _indexObserver;
// The default collation which is applied to operations and indices which have no collation of
// their own. The collection's validator will respect this collation.
diff --git a/src/mongo/db/catalog/collection_mock.h b/src/mongo/db/catalog/collection_mock.h
index e9bf3011686..ba7851ebc15 100644
--- a/src/mongo/db/catalog/collection_mock.h
+++ b/src/mongo/db/catalog/collection_mock.h
@@ -288,13 +288,6 @@ public:
std::abort();
}
- void informIndexObserver(OperationContext* opCtx,
- const IndexDescriptor* descriptor,
- const IndexKeyEntry& indexEntry,
- const ValidationOperation operation) const {
- std::abort();
- }
-
OptionalCollectionUUID uuid() const {
std::abort();
}
diff --git a/src/mongo/db/catalog/index_observer.cpp b/src/mongo/db/catalog/index_observer.cpp
deleted file mode 100644
index 58e270e5e69..00000000000
--- a/src/mongo/db/catalog/index_observer.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * Copyright (C) 2017 MongoDB Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the GNU Affero General Public License in all respects for
- * all of the code used other than as permitted herein. If you modify file(s)
- * with this exception, you may extend this exception to your version of the
- * file(s), but you are not obligated to do so. If you do not wish to do so,
- * delete this exception statement from your version. If you delete this
- * exception statement from all source files in the program, then also delete
- * it in the license file.
- */
-
-
-#include "mongo/platform/basic.h"
-
-#include "mongo/db/catalog/database.h"
-#include "mongo/db/catalog/database_holder.h"
-#include "mongo/db/catalog/index_consistency.h"
-#include "mongo/db/catalog/index_observer.h"
-#include "mongo/db/index/index_descriptor.h"
-#include "mongo/db/operation_context.h"
-
-
-namespace mongo {
-
-void IndexObserver::inform(OperationContext* opCtx,
- const IndexDescriptor* descriptor,
- const IndexKeyEntry& indexEntry,
- const ValidationOperation operation) {
-
- opCtx->recoveryUnit()->onCommit([this, opCtx, descriptor, indexEntry, operation] {
-
- NamespaceString nss(descriptor->indexNamespace());
- Database* database = dbHolder().get(opCtx, nss.db());
- invariant(database);
-
- Collection* collection = database->getCollection(opCtx, descriptor->parentNS());
- invariant(collection);
-
- _indexConsistency->applyChange(descriptor, indexEntry, operation);
- });
-}
-} // namespace
diff --git a/src/mongo/db/catalog/index_observer.h b/src/mongo/db/catalog/index_observer.h
deleted file mode 100644
index 778b75b0774..00000000000
--- a/src/mongo/db/catalog/index_observer.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-
- * Copyright (C) 2017 MongoDB Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the GNU Affero General Public License in all respects for
- * all of the code used other than as permitted herein. If you modify file(s)
- * with this exception, you may extend this exception to your version of the
- * file(s), but you are not obligated to do so. If you do not wish to do so,
- * delete this exception statement from your version. If you delete this
- * exception statement from all source files in the program, then also delete
- * it in the license file.
- */
-
-
-#pragma once
-
-#include "mongo/db/catalog/index_consistency.h"
-
-namespace mongo {
-
-class IndexDescriptor;
-class OperationContext;
-
-/**
- * The IndexObserver is used inside the IndexAccessMethod's insert, remove and update methods.
- * Upon a commit of a transaction, the IndexObserver is invoked and informs the IndexConsistency
- * class of any changes during a background validation.
- */
-class IndexObserver final {
-public:
- IndexObserver(IndexConsistency* consistency) : _indexConsistency(consistency) {}
-
- /**
- * Used to apply changes to the IndexConsistency instance whenever the observer is
- * informed of any changes from the IndexAccessMethod.
- */
- void inform(OperationContext* opCtx,
- const IndexDescriptor* descriptor,
- const IndexKeyEntry& indexEntry,
- const ValidationOperation operation);
-
-private:
- IndexConsistency* _indexConsistency; // Not owned
-};
-} // namespace
diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp
index 470b5210d57..7abcca26aad 100644
--- a/src/mongo/db/index/index_access_method.cpp
+++ b/src/mongo/db/index/index_access_method.cpp
@@ -40,7 +40,6 @@
#include "mongo/db/catalog/collection_impl.h"
#include "mongo/db/catalog/index_catalog.h"
#include "mongo/db/catalog/index_consistency.h"
-#include "mongo/db/catalog/index_observer.h"
#include "mongo/db/client.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
#include "mongo/db/curop.h"
@@ -137,8 +136,6 @@ Status IndexAccessMethod::insert(OperationContext* opCtx,
// Delegate to the subclass.
getKeys(obj, options.getKeysMode, &keys, &multikeyPaths);
- const ValidationOperation operation = ValidationOperation::INSERT;
-
Status ret = Status::OK();
for (BSONObjSet::const_iterator i = keys.begin(); i != keys.end(); ++i) {
Status status = _newInterface->insert(opCtx, *i, loc, options.dupsAllowed);
@@ -147,8 +144,6 @@ Status IndexAccessMethod::insert(OperationContext* opCtx,
if (status.isOK()) {
++*numInserted;
IndexKeyEntry indexEntry = IndexKeyEntry(*i, loc);
- _descriptor->getCollection()->informIndexObserver(
- opCtx, _descriptor, indexEntry, operation);
continue;
}
@@ -156,8 +151,6 @@ Status IndexAccessMethod::insert(OperationContext* opCtx,
if (status.code() == ErrorCodes::KeyTooLong && ignoreKeyTooLong(opCtx)) {
IndexKeyEntry indexEntry = IndexKeyEntry(*i, loc);
- _descriptor->getCollection()->informIndexObserver(
- opCtx, _descriptor, indexEntry, operation);
continue;
}
@@ -191,13 +184,9 @@ void IndexAccessMethod::removeOneKey(OperationContext* opCtx,
const RecordId& loc,
bool dupsAllowed) {
- const ValidationOperation operation = ValidationOperation::REMOVE;
-
try {
_newInterface->unindex(opCtx, key, loc, dupsAllowed);
IndexKeyEntry indexEntry = IndexKeyEntry(key, loc);
- _descriptor->getCollection()->informIndexObserver(
- opCtx, _descriptor, indexEntry, operation);
} catch (AssertionException& e) {
log() << "Assertion failure: _unindex failed " << _descriptor->indexNamespace();
log() << "Assertion failure: _unindex failed: " << redact(e) << " key:" << key.toString()
@@ -394,17 +383,11 @@ Status IndexAccessMethod::update(OperationContext* opCtx,
_btreeState->setMultikey(opCtx, ticket.newMultikeyPaths);
}
- const ValidationOperation removeOperation = ValidationOperation::REMOVE;
-
for (size_t i = 0; i < ticket.removed.size(); ++i) {
_newInterface->unindex(opCtx, ticket.removed[i], ticket.loc, ticket.dupsAllowed);
IndexKeyEntry indexEntry = IndexKeyEntry(ticket.removed[i], ticket.loc);
- _descriptor->getCollection()->informIndexObserver(
- opCtx, _descriptor, indexEntry, removeOperation);
}
- const ValidationOperation insertOperation = ValidationOperation::INSERT;
-
for (size_t i = 0; i < ticket.added.size(); ++i) {
Status status =
_newInterface->insert(opCtx, ticket.added[i], ticket.loc, ticket.dupsAllowed);
@@ -412,8 +395,6 @@ Status IndexAccessMethod::update(OperationContext* opCtx,
if (status.code() == ErrorCodes::KeyTooLong && ignoreKeyTooLong(opCtx)) {
// Ignore.
IndexKeyEntry indexEntry = IndexKeyEntry(ticket.added[i], ticket.loc);
- _descriptor->getCollection()->informIndexObserver(
- opCtx, _descriptor, indexEntry, insertOperation);
continue;
}
@@ -421,8 +402,6 @@ Status IndexAccessMethod::update(OperationContext* opCtx,
}
IndexKeyEntry indexEntry = IndexKeyEntry(ticket.added[i], ticket.loc);
- _descriptor->getCollection()->informIndexObserver(
- opCtx, _descriptor, indexEntry, insertOperation);
}
*numInserted = ticket.added.size();