summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gottlieb <daniel.gottlieb@mongodb.com>2018-06-27 12:47:00 -0400
committerDaniel Gottlieb <daniel.gottlieb@mongodb.com>2018-06-27 12:47:00 -0400
commit7bac7301b387e843e5672ad50d3ffcfcd807cb03 (patch)
tree594dba7d8898c73ab488137e20112cc99a2d5dda
parentdc849ad01396b513e61ae389b3bce4b28f3404be (diff)
downloadmongo-7bac7301b387e843e5672ad50d3ffcfcd807cb03.tar.gz
Revert "SERVER-35317: Preserve minVisible values when refreshing the catalog."
This reverts commit dc849ad01396b513e61ae389b3bce4b28f3404be.
-rw-r--r--jstests/noPassthrough/restart_catalog_preserves_min_visible.js44
-rw-r--r--src/mongo/db/catalog/catalog_control.cpp31
-rw-r--r--src/mongo/db/catalog/catalog_control.h10
-rw-r--r--src/mongo/db/commands/restart_catalog_command.cpp4
-rw-r--r--src/mongo/db/storage/kv/kv_storage_engine.cpp4
5 files changed, 8 insertions, 85 deletions
diff --git a/jstests/noPassthrough/restart_catalog_preserves_min_visible.js b/jstests/noPassthrough/restart_catalog_preserves_min_visible.js
deleted file mode 100644
index 4020873089d..00000000000
--- a/jstests/noPassthrough/restart_catalog_preserves_min_visible.js
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Restarting the catalog will destroy and recreate all database/collection/index objects from the
- * storage engine state. However, some fields like the `minimumVisibleSnapshot` timestamp are not
- * persisted to storage. This value is typically rehydrated when performing replication
- * recovery. However there are cases where reads can be at a timestamp prior to where replication
- * recovery begins. Those are fixed by copying the previous value over from the destroyed catalog
- * object to the recreated one.
- *
- * This test verifies the collection's minimum visible snapshot timestamp is appropriately copied
- * over.
- *
- * @tags: [requires_replication]
- */
-(function() {
- "use strict";
-
- let replSet = new ReplSetTest({name: "server35317", nodes: 1});
- replSet.startSet();
- replSet.initiate();
-
- let prim = replSet.getPrimary();
- let beforeIndexBuild = assert.commandWorked(prim.adminCommand(
- {configureFailPoint: "WTPreserveSnapshotHistoryIndefinitely",
- mode: "alwaysOn"}))["operationTime"];
- assert.commandWorked(prim.getDB("test").coll.insert({c: 1}));
- assert.commandWorked(prim.getDB("test").coll.createIndex({c: 1}));
- assert.commandWorked(prim.adminCommand({restartCatalog: 1}));
-
- let session = prim.startSession({causalConsistency: false});
- let sessionDb = session.getDatabase("test");
- // Prior to fixing SERVER-35317, this would crash a debug build, or return success on a
- // non-debug build. Now it should return an error. Specifically, this fails because we're
- // trying to read behind the minimum visible snapshot timestamp for the `test.coll`
- // collection.
- assert.commandFailed(sessionDb.runCommand({
- find: "coll",
- filter: {c: 1},
- readConcern: {level: "snapshot", atClusterTime: beforeIndexBuild},
- txnNumber: NumberLong(0)
- }));
-
- session.endSession();
- replSet.stopSet();
-})();
diff --git a/src/mongo/db/catalog/catalog_control.cpp b/src/mongo/db/catalog/catalog_control.cpp
index e0421fc338f..7edb945faa5 100644
--- a/src/mongo/db/catalog/catalog_control.cpp
+++ b/src/mongo/db/catalog/catalog_control.cpp
@@ -43,30 +43,9 @@
namespace mongo {
namespace catalog {
-MinVisibleTimestampMap closeCatalog(OperationContext* opCtx) {
+void closeCatalog(OperationContext* opCtx) {
invariant(opCtx->lockState()->isW());
- MinVisibleTimestampMap minVisibleTimestampMap;
- std::vector<std::string> allDbs;
- opCtx->getServiceContext()->getStorageEngine()->listDatabases(&allDbs);
-
- const auto& databaseHolder = DatabaseHolder::getDatabaseHolder();
- for (auto&& dbName : allDbs) {
- const auto db = databaseHolder.get(opCtx, dbName);
- for (Collection* coll : *db) {
- OptionalCollectionUUID uuid = coll->uuid();
- boost::optional<Timestamp> minVisible = coll->getMinimumVisibleSnapshot();
-
- // If there's a minimum visible, invariant there's also a UUID.
- invariant(!minVisible || uuid);
- if (uuid && minVisible) {
- LOG(1) << "closeCatalog: preserving min visible timestamp. Collection: "
- << coll->ns() << " UUID: " << uuid << " TS: " << minVisible;
- minVisibleTimestampMap[*uuid] = *minVisible;
- }
- }
- }
-
// Closing UUID Catalog: only lookupNSSByUUID will fall back to using pre-closing state to
// allow authorization for currently unknown UUIDs. This is needed because authorization needs
// to work before acquiring locks, and might otherwise spuriously regard a UUID as unknown
@@ -82,11 +61,9 @@ MinVisibleTimestampMap closeCatalog(OperationContext* opCtx) {
// Close the storage engine's catalog.
log() << "closeCatalog: closing storage engine catalog";
opCtx->getServiceContext()->getStorageEngine()->closeCatalog(opCtx);
-
- return minVisibleTimestampMap;
}
-void openCatalog(OperationContext* opCtx, const MinVisibleTimestampMap& minVisibleTimestampMap) {
+void openCatalog(OperationContext* opCtx) {
invariant(opCtx->lockState()->isW());
// Load the catalog in the storage engine.
@@ -188,10 +165,6 @@ void openCatalog(OperationContext* opCtx, const MinVisibleTimestampMap& minVisib
<< collName;
uuidCatalog.registerUUIDCatalogEntry(*uuid, collection);
- if (minVisibleTimestampMap.count(*uuid) > 0) {
- collection->setMinimumVisibleSnapshot(minVisibleTimestampMap.find(*uuid)->second);
- }
-
// If this is the oplog collection, re-establish the replication system's cached pointer
// to the oplog.
if (collNss.isOplog()) {
diff --git a/src/mongo/db/catalog/catalog_control.h b/src/mongo/db/catalog/catalog_control.h
index 97053b07d55..85eff55ec25 100644
--- a/src/mongo/db/catalog/catalog_control.h
+++ b/src/mongo/db/catalog/catalog_control.h
@@ -26,29 +26,23 @@
* then also delete it in the license file.
*/
-#include <map>
-
#include "mongo/db/operation_context.h"
namespace mongo {
namespace catalog {
-
-using MinVisibleTimestamp = Timestamp;
-using MinVisibleTimestampMap = std::map<UUID, MinVisibleTimestamp>;
-
/**
* Closes the catalog, destroying all associated in-memory data structures for all databases. After
* a call to this function, it is illegal to access the catalog before calling openCatalog().
*
* Must be called with the global lock acquired in exclusive mode.
*/
-MinVisibleTimestampMap closeCatalog(OperationContext* opCtx);
+void closeCatalog(OperationContext* opCtx);
/**
* Restores the catalog and all in-memory state after a call to closeCatalog().
*
* Must be called with the global lock acquired in exclusive mode.
*/
-void openCatalog(OperationContext* opCtx, const MinVisibleTimestampMap& catalogState);
+void openCatalog(OperationContext* opCtx);
} // namespace catalog
} // namespace mongo
diff --git a/src/mongo/db/commands/restart_catalog_command.cpp b/src/mongo/db/commands/restart_catalog_command.cpp
index 8847e04eca9..a9bdbebbc1e 100644
--- a/src/mongo/db/commands/restart_catalog_command.cpp
+++ b/src/mongo/db/commands/restart_catalog_command.cpp
@@ -114,12 +114,12 @@ public:
});
log() << "Closing database catalog";
- auto state = catalog::closeCatalog(opCtx);
+ catalog::closeCatalog(opCtx);
restoreOplogPointerGuard.Dismiss();
log() << "Reopening database catalog";
- catalog::openCatalog(opCtx, state);
+ catalog::openCatalog(opCtx);
return true;
}
diff --git a/src/mongo/db/storage/kv/kv_storage_engine.cpp b/src/mongo/db/storage/kv/kv_storage_engine.cpp
index 16eed29b2f9..f7deeb3396f 100644
--- a/src/mongo/db/storage/kv/kv_storage_engine.cpp
+++ b/src/mongo/db/storage/kv/kv_storage_engine.cpp
@@ -543,14 +543,14 @@ StatusWith<Timestamp> KVStorageEngine::recoverToStableTimestamp(OperationContext
wuow.commit();
}
- auto state = catalog::closeCatalog(opCtx);
+ catalog::closeCatalog(opCtx);
StatusWith<Timestamp> swTimestamp = _engine->recoverToStableTimestamp(opCtx);
if (!swTimestamp.isOK()) {
return swTimestamp;
}
- catalog::openCatalog(opCtx, state);
+ catalog::openCatalog(opCtx);
log() << "recoverToStableTimestamp successful. Stable Timestamp: " << swTimestamp.getValue();
return {swTimestamp.getValue()};