summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorauto-revert-processor <dev-prod-dag@mongodb.com>2022-04-07 03:58:33 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-04-07 05:32:31 +0000
commitbe4ed43dc2b31c4f7ef607fb4556bb1991f9dfad (patch)
treef4b54e4ae236ff8a561f791747a86bfa8d9bfb66 /src
parentdf9851154bc9847dc6a736dcdb0e85c2176d0520 (diff)
downloadmongo-be4ed43dc2b31c4f7ef607fb4556bb1991f9dfad.tar.gz
Revert "SERVER-64832: Convert WT unittests to use replica set logging settings."
This reverts commit f8b4247e38f3ac7fd3dc37b3031469b2d1c53999.
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/catalog/collection_impl.cpp2
-rw-r--r--src/mongo/db/catalog/index_build_block.cpp6
-rw-r--r--src/mongo/db/catalog/index_catalog_impl.cpp4
-rw-r--r--src/mongo/db/pipeline/document_source_check_resume_token_test.cpp2
-rw-r--r--src/mongo/db/storage/devnull/devnull_kv_engine.cpp7
-rw-r--r--src/mongo/db/storage/devnull/devnull_kv_engine.h6
-rw-r--r--src/mongo/db/storage/durable_catalog.h2
-rw-r--r--src/mongo/db/storage/durable_catalog_impl.cpp62
-rw-r--r--src/mongo/db/storage/durable_catalog_impl.h2
-rw-r--r--src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_kv_engine.cpp20
-rw-r--r--src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_kv_engine.h7
-rw-r--r--src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_kv_engine_test.cpp32
-rw-r--r--src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_sorted_impl_test.cpp6
-rw-r--r--src/mongo/db/storage/kv/kv_drop_pending_ident_reaper_test.cpp6
-rw-r--r--src/mongo/db/storage/kv/kv_engine.h8
-rw-r--r--src/mongo/db/storage/kv/kv_engine_test_harness.cpp123
-rw-r--r--src/mongo/db/storage/kv/kv_engine_timestamps_test.cpp4
-rw-r--r--src/mongo/db/storage/recovery_unit.h6
-rw-r--r--src/mongo/db/storage/storage_engine_impl.cpp22
-rw-r--r--src/mongo/db/storage/storage_engine_test_fixture.h2
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp32
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_index.h9
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp83
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h6
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp35
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp40
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h8
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp14
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test_harness.cpp38
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp5
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp14
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp23
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_standard_record_store_test.cpp2
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp24
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_util.h2
35 files changed, 286 insertions, 378 deletions
diff --git a/src/mongo/db/catalog/collection_impl.cpp b/src/mongo/db/catalog/collection_impl.cpp
index ecdd237883d..135a086fa8b 100644
--- a/src/mongo/db/catalog/collection_impl.cpp
+++ b/src/mongo/db/catalog/collection_impl.cpp
@@ -2170,7 +2170,7 @@ Status CollectionImpl::prepareForIndexBuild(OperationContext* opCtx,
md.insertIndex(std::move(indexMetaData));
});
- return durableCatalog->createIndex(opCtx, getCatalogId(), ns(), getCollectionOptions(), spec);
+ return durableCatalog->createIndex(opCtx, getCatalogId(), getCollectionOptions(), spec);
}
boost::optional<UUID> CollectionImpl::getIndexBuildUUID(StringData indexName) const {
diff --git a/src/mongo/db/catalog/index_build_block.cpp b/src/mongo/db/catalog/index_build_block.cpp
index 204902b1eb2..dc7ef8e3fbd 100644
--- a/src/mongo/db/catalog/index_build_block.cpp
+++ b/src/mongo/db/catalog/index_build_block.cpp
@@ -107,11 +107,7 @@ Status IndexBuildBlock::initForResume(OperationContext* opCtx,
// A bulk cursor can only be opened on a fresh table, so we drop the table that was created
// before shutdown and recreate it.
auto status = DurableCatalog::get(opCtx)->dropAndRecreateIndexIdentForResume(
- opCtx,
- collection->ns(),
- collection->getCollectionOptions(),
- descriptor,
- indexCatalogEntry->getIdent());
+ opCtx, collection->getCollectionOptions(), descriptor, indexCatalogEntry->getIdent());
if (!status.isOK())
return status;
}
diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp
index c2416ff122c..ff7a21d3783 100644
--- a/src/mongo/db/catalog/index_catalog_impl.cpp
+++ b/src/mongo/db/catalog/index_catalog_impl.cpp
@@ -535,8 +535,8 @@ IndexCatalogEntry* IndexCatalogImpl::createIndexEntry(OperationContext* opCtx,
}
const auto& collOptions = collection->getCollectionOptions();
- std::unique_ptr<SortedDataInterface> sdi = engine->getEngine()->getSortedDataInterface(
- opCtx, collection->ns(), collOptions, ident, desc);
+ std::unique_ptr<SortedDataInterface> sdi =
+ engine->getEngine()->getSortedDataInterface(opCtx, collOptions, ident, desc);
std::unique_ptr<IndexAccessMethod> accessMethod =
IndexAccessMethodFactory::get(opCtx)->make(entry.get(), std::move(sdi));
diff --git a/src/mongo/db/pipeline/document_source_check_resume_token_test.cpp b/src/mongo/db/pipeline/document_source_check_resume_token_test.cpp
index 5a225a35fca..05c7accf3a9 100644
--- a/src/mongo/db/pipeline/document_source_check_resume_token_test.cpp
+++ b/src/mongo/db/pipeline/document_source_check_resume_token_test.cpp
@@ -97,7 +97,7 @@ class ChangeStreamOplogCollectionMock : public CollectionMock {
public:
ChangeStreamOplogCollectionMock() : CollectionMock(NamespaceString::kRsOplogNamespace) {
_recordStore =
- _devNullEngine.getRecordStore(nullptr, NamespaceString::kRsOplogNamespace, "", {});
+ _devNullEngine.getRecordStore(nullptr, NamespaceString::kRsOplogNamespace.ns(), "", {});
}
void push_back(Document doc) {
diff --git a/src/mongo/db/storage/devnull/devnull_kv_engine.cpp b/src/mongo/db/storage/devnull/devnull_kv_engine.cpp
index 86ea5ece9c4..7f57f9be911 100644
--- a/src/mongo/db/storage/devnull/devnull_kv_engine.cpp
+++ b/src/mongo/db/storage/devnull/devnull_kv_engine.cpp
@@ -260,13 +260,13 @@ DevNullKVEngine::DevNullKVEngine() {
}
std::unique_ptr<RecordStore> DevNullKVEngine::getRecordStore(OperationContext* opCtx,
- const NamespaceString& nss,
+ StringData ns,
StringData ident,
const CollectionOptions& options) {
if (ident == "_mdb_catalog") {
- return std::make_unique<EphemeralForTestRecordStore>(nss.ns(), ident, &_catalogInfo);
+ return std::make_unique<EphemeralForTestRecordStore>(ns, ident, &_catalogInfo);
}
- return std::make_unique<DevNullRecordStore>(nss.ns(), ident, options, KeyFormat::Long);
+ return std::make_unique<DevNullRecordStore>(ns, ident, options, KeyFormat::Long);
}
std::unique_ptr<RecordStore> DevNullKVEngine::makeTemporaryRecordStore(OperationContext* opCtx,
@@ -277,7 +277,6 @@ std::unique_ptr<RecordStore> DevNullKVEngine::makeTemporaryRecordStore(Operation
std::unique_ptr<SortedDataInterface> DevNullKVEngine::getSortedDataInterface(
OperationContext* opCtx,
- const NamespaceString& nss,
const CollectionOptions& collOptions,
StringData ident,
const IndexDescriptor* desc) {
diff --git a/src/mongo/db/storage/devnull/devnull_kv_engine.h b/src/mongo/db/storage/devnull/devnull_kv_engine.h
index 1e14dbf2937..7553e808960 100644
--- a/src/mongo/db/storage/devnull/devnull_kv_engine.h
+++ b/src/mongo/db/storage/devnull/devnull_kv_engine.h
@@ -53,7 +53,7 @@ public:
}
virtual Status createRecordStore(OperationContext* opCtx,
- const NamespaceString& nss,
+ StringData ns,
StringData ident,
const CollectionOptions& options,
KeyFormat keyFormat = KeyFormat::Long) {
@@ -61,7 +61,7 @@ public:
}
virtual std::unique_ptr<RecordStore> getRecordStore(OperationContext* opCtx,
- const NamespaceString& nss,
+ StringData ns,
StringData ident,
const CollectionOptions& options);
@@ -70,7 +70,6 @@ public:
KeyFormat keyFormat) override;
virtual Status createSortedDataInterface(OperationContext* opCtx,
- const NamespaceString& nss,
const CollectionOptions& collOptions,
StringData ident,
const IndexDescriptor* desc) {
@@ -83,7 +82,6 @@ public:
virtual std::unique_ptr<SortedDataInterface> getSortedDataInterface(
OperationContext* opCtx,
- const NamespaceString& nss,
const CollectionOptions& collOptions,
StringData ident,
const IndexDescriptor* desc);
diff --git a/src/mongo/db/storage/durable_catalog.h b/src/mongo/db/storage/durable_catalog.h
index 49db4546918..d4a76b522b1 100644
--- a/src/mongo/db/storage/durable_catalog.h
+++ b/src/mongo/db/storage/durable_catalog.h
@@ -153,7 +153,6 @@ public:
virtual Status createIndex(OperationContext* opCtx,
RecordId catalogId,
- const NamespaceString& nss,
const CollectionOptions& collOptions,
const IndexDescriptor* spec) = 0;
@@ -203,7 +202,6 @@ public:
* Drops the provided ident and recreates it as empty for use in resuming an index build.
*/
virtual Status dropAndRecreateIndexIdentForResume(OperationContext* opCtx,
- const NamespaceString& nss,
const CollectionOptions& collOptions,
const IndexDescriptor* spec,
StringData ident) = 0;
diff --git a/src/mongo/db/storage/durable_catalog_impl.cpp b/src/mongo/db/storage/durable_catalog_impl.cpp
index 13b86f9af07..2cb14f50fac 100644
--- a/src/mongo/db/storage/durable_catalog_impl.cpp
+++ b/src/mongo/db/storage/durable_catalog_impl.cpp
@@ -138,6 +138,48 @@ std::string escapeDbName(StringData dbname) {
bool indexTypeSupportsPathLevelMultikeyTracking(StringData accessMethod) {
return accessMethod == IndexNames::BTREE || accessMethod == IndexNames::GEO_2DSPHERE;
}
+
+/**
+ * Returns true if writes to the catalog entry for the input namespace require being timestamped.
+ */
+bool requiresTimestampForCatalogWrite(OperationContext* opCtx, const NamespaceString& nss) {
+ if (!nss.isReplicated() || nss.coll().startsWith("tmp.mr.") || nss.isDropPendingNamespace()) {
+ return false;
+ }
+
+ auto replCoord = repl::ReplicationCoordinator::get(opCtx);
+ if (!replCoord->isReplEnabled()) {
+ return false;
+ }
+
+ if (!opCtx->writesAreReplicated()) {
+ return false;
+ }
+
+ // If there is a timestamp already assigned, there's no need to explicitly assign a timestamp.
+ if (opCtx->recoveryUnit()->isTimestamped()) {
+ return false;
+ }
+
+ // Nodes in `startup` do not need to timestamp writes.
+ // Nodes in the oplog application phase of initial sync (`startup2`) must not timestamp writes
+ // before the `initialDataTimestamp`. Nodes in initial sync may also be in the `removed` state
+ // due to DNS resolution errors; they may continue writing during that time.
+ const auto memberState = replCoord->getMemberState();
+ if (memberState.startup() || memberState.startup2() || memberState.removed()) {
+ return false;
+ }
+
+ // When rollback completes, index builds may be restarted, which requires untimestamped catalog
+ // writes. Additionally, it's illegal to timestamp a write later than the timestamp associated
+ // with the node exiting the rollback state.
+ if (memberState.rollback()) {
+ return false;
+ }
+
+ return true;
+}
+
} // namespace
class DurableCatalogImpl::AddIdentChange : public RecoveryUnit::Change {
@@ -440,6 +482,10 @@ void DurableCatalogImpl::putMetaData(OperationContext* opCtx,
obj = b.obj();
}
+ if (requiresTimestampForCatalogWrite(opCtx, nss)) {
+ opCtx->recoveryUnit()->setMustBeTimestamped();
+ }
+
LOGV2_DEBUG(22211, 3, "recording new metadata: {obj}", "obj"_attr = obj);
Status status = _rs->updateRecord(opCtx, catalogId, obj.objdata(), obj.objsize());
fassert(28521, status);
@@ -476,6 +522,10 @@ Status DurableCatalogImpl::_replaceEntry(OperationContext* opCtx,
it->second.nss = fromName;
});
+ if (requiresTimestampForCatalogWrite(opCtx, fromName)) {
+ opCtx->recoveryUnit()->setMustBeTimestamped();
+ }
+
return Status::OK();
}
@@ -622,7 +672,7 @@ StatusWith<std::pair<RecordId, std::unique_ptr<RecordStore>>> DurableCatalogImpl
return KeyFormat::Long;
}();
Status status =
- _engine->getEngine()->createRecordStore(opCtx, nss, entry.ident, options, keyFormat);
+ _engine->getEngine()->createRecordStore(opCtx, nss.ns(), entry.ident, options, keyFormat);
if (!status.isOK())
return status;
@@ -632,7 +682,7 @@ StatusWith<std::pair<RecordId, std::unique_ptr<RecordStore>>> DurableCatalogImpl
catalog->_engine->getEngine()->dropIdent(ru, ident).ignore();
});
- auto rs = _engine->getEngine()->getRecordStore(opCtx, nss, entry.ident, options);
+ auto rs = _engine->getEngine()->getRecordStore(opCtx, nss.ns(), entry.ident, options);
invariant(rs);
return std::pair<RecordId, std::unique_ptr<RecordStore>>(entry.catalogId, std::move(rs));
@@ -640,13 +690,12 @@ StatusWith<std::pair<RecordId, std::unique_ptr<RecordStore>>> DurableCatalogImpl
Status DurableCatalogImpl::createIndex(OperationContext* opCtx,
RecordId catalogId,
- const NamespaceString& nss,
const CollectionOptions& collOptions,
const IndexDescriptor* spec) {
std::string ident = getIndexIdent(opCtx, catalogId, spec->indexName());
auto kvEngine = _engine->getEngine();
- const Status status = kvEngine->createSortedDataInterface(opCtx, nss, collOptions, ident, spec);
+ const Status status = kvEngine->createSortedDataInterface(opCtx, collOptions, ident, spec);
if (status.isOK()) {
opCtx->recoveryUnit()->onRollback([this, ident, recoveryUnit = opCtx->recoveryUnit()]() {
// Intentionally ignoring failure.
@@ -751,7 +800,7 @@ StatusWith<DurableCatalog::ImportResult> DurableCatalogImpl::importCollection(
}
}
- auto rs = _engine->getEngine()->getRecordStore(opCtx, nss, entry.ident, md.options);
+ auto rs = _engine->getEngine()->getRecordStore(opCtx, nss.ns(), entry.ident, md.options);
invariant(rs);
return DurableCatalog::ImportResult(entry.catalogId, std::move(rs), md.options.uuid.get());
@@ -784,7 +833,6 @@ Status DurableCatalogImpl::dropCollection(OperationContext* opCtx, RecordId cata
}
Status DurableCatalogImpl::dropAndRecreateIndexIdentForResume(OperationContext* opCtx,
- const NamespaceString& nss,
const CollectionOptions& collOptions,
const IndexDescriptor* spec,
StringData ident) {
@@ -792,7 +840,7 @@ Status DurableCatalogImpl::dropAndRecreateIndexIdentForResume(OperationContext*
if (!status.isOK())
return status;
- status = _engine->getEngine()->createSortedDataInterface(opCtx, nss, collOptions, ident, spec);
+ status = _engine->getEngine()->createSortedDataInterface(opCtx, collOptions, ident, spec);
return status;
}
diff --git a/src/mongo/db/storage/durable_catalog_impl.h b/src/mongo/db/storage/durable_catalog_impl.h
index 873733d58b4..fe91e714896 100644
--- a/src/mongo/db/storage/durable_catalog_impl.h
+++ b/src/mongo/db/storage/durable_catalog_impl.h
@@ -113,7 +113,6 @@ public:
Status createIndex(OperationContext* opCtx,
RecordId catalogId,
- const NamespaceString& nss,
const CollectionOptions& collOptions,
const IndexDescriptor* spec);
@@ -131,7 +130,6 @@ public:
Status dropCollection(OperationContext* opCtx, RecordId catalogId);
Status dropAndRecreateIndexIdentForResume(OperationContext* opCtx,
- const NamespaceString& nss,
const CollectionOptions& collOptions,
const IndexDescriptor* spec,
StringData ident);
diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_kv_engine.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_kv_engine.cpp
index 3d4a3ce9976..fc993df8c49 100644
--- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_kv_engine.cpp
+++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_kv_engine.cpp
@@ -67,7 +67,7 @@ mongo::RecoveryUnit* KVEngine::newRecoveryUnit() {
}
Status KVEngine::createRecordStore(OperationContext* opCtx,
- const NamespaceString& nss,
+ StringData ns,
StringData ident,
const CollectionOptions& options,
KeyFormat keyFormat) {
@@ -97,20 +97,20 @@ std::unique_ptr<mongo::RecordStore> KVEngine::makeTemporaryRecordStore(Operation
std::unique_ptr<mongo::RecordStore> KVEngine::getRecordStore(OperationContext* unused,
- const NamespaceString& nss,
+ StringData ns,
StringData ident,
const CollectionOptions& options) {
std::unique_ptr<mongo::RecordStore> recordStore;
const auto keyFormat = options.clusteredIndex ? KeyFormat::String : KeyFormat::Long;
if (options.capped) {
- recordStore = std::make_unique<RecordStore>(nss.ns(),
+ recordStore = std::make_unique<RecordStore>(ns,
ident,
keyFormat,
options.capped,
/*cappedCallback*/ nullptr,
_visibilityManager.get());
} else {
- recordStore = std::make_unique<RecordStore>(nss.ns(), ident, keyFormat, options.capped);
+ recordStore = std::make_unique<RecordStore>(ns, ident, keyFormat, options.capped);
}
stdx::lock_guard lock(_identsLock);
_idents[ident.toString()] = true;
@@ -133,7 +133,6 @@ bool KVEngine::trySwapMaster(StringStore& newMaster, uint64_t version) {
Status KVEngine::createSortedDataInterface(OperationContext* opCtx,
- const NamespaceString& nss,
const CollectionOptions& collOptions,
StringData ident,
const IndexDescriptor* desc) {
@@ -153,20 +152,15 @@ Status KVEngine::importSortedDataInterface(OperationContext* opCtx,
std::unique_ptr<mongo::SortedDataInterface> KVEngine::getSortedDataInterface(
OperationContext* opCtx,
- const NamespaceString& nss,
const CollectionOptions& collOptions,
StringData ident,
const IndexDescriptor* desc) {
auto rsKeyFormat = collOptions.clusteredIndex ? KeyFormat::String : KeyFormat::Long;
- return getSortedDataInterface(opCtx, nss, rsKeyFormat, ident, desc);
+ return getSortedDataInterface(opCtx, rsKeyFormat, ident, desc);
}
std::unique_ptr<mongo::SortedDataInterface> KVEngine::getSortedDataInterface(
- OperationContext* opCtx,
- const NamespaceString& nss,
- KeyFormat rsKeyFormat,
- StringData ident,
- const IndexDescriptor* desc) {
+ OperationContext* opCtx, KeyFormat rsKeyFormat, StringData ident, const IndexDescriptor* desc) {
{
stdx::lock_guard lock(_identsLock);
_idents[ident.toString()] = false;
@@ -189,7 +183,7 @@ Status KVEngine::dropIdent(mongo::RecoveryUnit* ru,
lock.unlock();
if (isRecordStore) { // ident is RecordStore.
CollectionOptions s;
- auto rs = getRecordStore(/*opCtx=*/nullptr, NamespaceString(""), ident, s);
+ auto rs = getRecordStore(/*opCtx=*/nullptr, ""_sd, ident, s);
dropStatus =
checked_cast<RecordStore*>(rs.get())->truncateWithoutUpdatingCount(ru).getStatus();
} else { // ident is SortedDataInterface.
diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_kv_engine.h b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_kv_engine.h
index 8844100fbae..e8b2fc79e12 100644
--- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_kv_engine.h
+++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_kv_engine.h
@@ -55,7 +55,7 @@ public:
virtual mongo::RecoveryUnit* newRecoveryUnit();
virtual Status createRecordStore(OperationContext* opCtx,
- const NamespaceString& nss,
+ StringData ns,
StringData ident,
const CollectionOptions& options,
KeyFormat keyFormat = KeyFormat::Long);
@@ -66,7 +66,7 @@ public:
const ImportOptions& importOptions) final;
virtual std::unique_ptr<mongo::RecordStore> getRecordStore(OperationContext* opCtx,
- const NamespaceString& nss,
+ StringData ns,
StringData ident,
const CollectionOptions& options);
@@ -74,7 +74,6 @@ public:
OperationContext* opCtx, StringData ident, KeyFormat keyFormat) override;
virtual Status createSortedDataInterface(OperationContext* opCtx,
- const NamespaceString& nss,
const CollectionOptions& collOptions,
StringData ident,
const IndexDescriptor* desc);
@@ -90,14 +89,12 @@ public:
virtual std::unique_ptr<mongo::SortedDataInterface> getSortedDataInterface(
OperationContext* opCtx,
- const NamespaceString& nss,
KeyFormat rsKeyFormat,
StringData ident,
const IndexDescriptor* desc);
virtual std::unique_ptr<mongo::SortedDataInterface> getSortedDataInterface(
OperationContext* opCtx,
- const NamespaceString& nss,
const CollectionOptions& collOptions,
StringData ident,
const IndexDescriptor* desc);
diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_kv_engine_test.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_kv_engine_test.cpp
index 88a76d7cab6..7eee134ed39 100644
--- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_kv_engine_test.cpp
+++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_kv_engine_test.cpp
@@ -99,8 +99,8 @@ TEST_F(EphemeralForTestKVEngineTest, AvailableHistoryUpdate) {
std::unique_ptr<mongo::RecordStore> rs;
{
OperationContextFromKVEngine opCtx(_engine);
- ASSERT_OK(_engine->createRecordStore(&opCtx, nss, ident, defaultCollectionOptions));
- rs = _engine->getRecordStore(&opCtx, nss, ident, defaultCollectionOptions);
+ ASSERT_OK(_engine->createRecordStore(&opCtx, nss.ns(), ident, defaultCollectionOptions));
+ rs = _engine->getRecordStore(&opCtx, nss.ns(), ident, defaultCollectionOptions);
ASSERT(rs);
}
@@ -136,8 +136,8 @@ TEST_F(EphemeralForTestKVEngineTest, PinningOldestTimestampWithReadTransaction)
std::unique_ptr<mongo::RecordStore> rs;
{
OperationContextFromKVEngine opCtx(_engine);
- ASSERT_OK(_engine->createRecordStore(&opCtx, nss, ident, defaultCollectionOptions));
- rs = _engine->getRecordStore(&opCtx, nss, ident, defaultCollectionOptions);
+ ASSERT_OK(_engine->createRecordStore(&opCtx, nss.ns(), ident, defaultCollectionOptions));
+ rs = _engine->getRecordStore(&opCtx, nss.ns(), ident, defaultCollectionOptions);
ASSERT(rs);
}
@@ -182,8 +182,8 @@ TEST_F(EphemeralForTestKVEngineTest, SettingOldestTimestampClearsHistory) {
std::unique_ptr<mongo::RecordStore> rs;
{
OperationContextFromKVEngine opCtx(_engine);
- ASSERT_OK(_engine->createRecordStore(&opCtx, nss, ident, defaultCollectionOptions));
- rs = _engine->getRecordStore(&opCtx, nss, ident, defaultCollectionOptions);
+ ASSERT_OK(_engine->createRecordStore(&opCtx, nss.ns(), ident, defaultCollectionOptions));
+ rs = _engine->getRecordStore(&opCtx, nss.ns(), ident, defaultCollectionOptions);
ASSERT(rs);
}
@@ -228,8 +228,8 @@ TEST_F(EphemeralForTestKVEngineTest, SettingOldestTimestampToMax) {
std::unique_ptr<mongo::RecordStore> rs;
{
OperationContextFromKVEngine opCtx(_engine);
- ASSERT_OK(_engine->createRecordStore(&opCtx, nss, ident, defaultCollectionOptions));
- rs = _engine->getRecordStore(&opCtx, nss, ident, defaultCollectionOptions);
+ ASSERT_OK(_engine->createRecordStore(&opCtx, nss.ns(), ident, defaultCollectionOptions));
+ rs = _engine->getRecordStore(&opCtx, nss.ns(), ident, defaultCollectionOptions);
ASSERT(rs);
}
@@ -259,8 +259,8 @@ TEST_F(EphemeralForTestKVEngineTest, CleanHistoryWithOpenTransaction) {
std::unique_ptr<mongo::RecordStore> rs;
{
OperationContextFromKVEngine opCtx(_engine);
- ASSERT_OK(_engine->createRecordStore(&opCtx, nss, ident, defaultCollectionOptions));
- rs = _engine->getRecordStore(&opCtx, nss, ident, defaultCollectionOptions);
+ ASSERT_OK(_engine->createRecordStore(&opCtx, nss.ns(), ident, defaultCollectionOptions));
+ rs = _engine->getRecordStore(&opCtx, nss.ns(), ident, defaultCollectionOptions);
ASSERT(rs);
}
@@ -322,8 +322,8 @@ TEST_F(EphemeralForTestKVEngineTest, ReadOlderSnapshotsSimple) {
std::unique_ptr<mongo::RecordStore> rs;
{
OperationContextFromKVEngine opCtx(_engine);
- ASSERT_OK(_engine->createRecordStore(&opCtx, nss, ident, defaultCollectionOptions));
- rs = _engine->getRecordStore(&opCtx, nss, ident, defaultCollectionOptions);
+ ASSERT_OK(_engine->createRecordStore(&opCtx, nss.ns(), ident, defaultCollectionOptions));
+ rs = _engine->getRecordStore(&opCtx, nss.ns(), ident, defaultCollectionOptions);
ASSERT(rs);
}
@@ -370,8 +370,8 @@ TEST_F(EphemeralForTestKVEngineTest, ReadOutdatedSnapshot) {
std::unique_ptr<mongo::RecordStore> rs;
{
OperationContextFromKVEngine opCtx(_engine);
- ASSERT_OK(_engine->createRecordStore(&opCtx, nss, ident, defaultCollectionOptions));
- rs = _engine->getRecordStore(&opCtx, nss, ident, defaultCollectionOptions);
+ ASSERT_OK(_engine->createRecordStore(&opCtx, nss.ns(), ident, defaultCollectionOptions));
+ rs = _engine->getRecordStore(&opCtx, nss.ns(), ident, defaultCollectionOptions);
ASSERT(rs);
}
@@ -418,8 +418,8 @@ TEST_F(EphemeralForTestKVEngineTest, SetReadTimestampBehindOldestTimestamp) {
std::unique_ptr<mongo::RecordStore> rs;
{
OperationContextFromKVEngine opCtx(_engine);
- ASSERT_OK(_engine->createRecordStore(&opCtx, nss, ident, defaultCollectionOptions));
- rs = _engine->getRecordStore(&opCtx, nss, ident, defaultCollectionOptions);
+ ASSERT_OK(_engine->createRecordStore(&opCtx, nss.ns(), ident, defaultCollectionOptions));
+ rs = _engine->getRecordStore(&opCtx, nss.ns(), ident, defaultCollectionOptions);
ASSERT(rs);
}
diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_sorted_impl_test.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_sorted_impl_test.cpp
index a36311aa472..4798342147b 100644
--- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_sorted_impl_test.cpp
+++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_sorted_impl_test.cpp
@@ -64,8 +64,7 @@ public:
IndexDescriptor desc("", spec);
invariant(desc.isIdIndex());
- return _kvEngine.getSortedDataInterface(
- &opCtx, NamespaceString(ns), CollectionOptions(), "ident"_sd, &desc);
+ return _kvEngine.getSortedDataInterface(&opCtx, CollectionOptions(), "ident"_sd, &desc);
}
std::unique_ptr<mongo::SortedDataInterface> newSortedDataInterface(bool unique,
@@ -87,8 +86,7 @@ public:
auto collection = std::make_unique<CollectionMock>(NamespaceString(ns));
_descs.emplace_back("", spec);
- return _kvEngine.getSortedDataInterface(
- &opCtx, NamespaceString(ns), keyFormat, "ident"_sd, &_descs.back());
+ return _kvEngine.getSortedDataInterface(&opCtx, keyFormat, "ident"_sd, &_descs.back());
}
std::unique_ptr<mongo::RecoveryUnit> newRecoveryUnit() final {
diff --git a/src/mongo/db/storage/kv/kv_drop_pending_ident_reaper_test.cpp b/src/mongo/db/storage/kv/kv_drop_pending_ident_reaper_test.cpp
index 4c2280c3fda..c206a052efc 100644
--- a/src/mongo/db/storage/kv/kv_drop_pending_ident_reaper_test.cpp
+++ b/src/mongo/db/storage/kv/kv_drop_pending_ident_reaper_test.cpp
@@ -57,21 +57,20 @@ public:
return nullptr;
}
std::unique_ptr<RecordStore> getRecordStore(OperationContext* opCtx,
- const NamespaceString& nss,
+ StringData ns,
StringData ident,
const CollectionOptions& options) override {
return {};
}
std::unique_ptr<SortedDataInterface> getSortedDataInterface(
OperationContext* opCtx,
- const NamespaceString& nss,
const CollectionOptions& collOptions,
StringData ident,
const IndexDescriptor* desc) override {
return nullptr;
}
Status createRecordStore(OperationContext* opCtx,
- const NamespaceString& nss,
+ StringData ns,
StringData ident,
const CollectionOptions& options,
KeyFormat keyFormat) override {
@@ -83,7 +82,6 @@ public:
return {};
}
Status createSortedDataInterface(OperationContext* opCtx,
- const NamespaceString& nss,
const CollectionOptions& collOptions,
StringData ident,
const IndexDescriptor* desc) override {
diff --git a/src/mongo/db/storage/kv/kv_engine.h b/src/mongo/db/storage/kv/kv_engine.h
index 25f52f0e40f..17758b87ab1 100644
--- a/src/mongo/db/storage/kv/kv_engine.h
+++ b/src/mongo/db/storage/kv/kv_engine.h
@@ -79,13 +79,12 @@ public:
* @param ident Will be created if it does not already exist.
*/
virtual std::unique_ptr<RecordStore> getRecordStore(OperationContext* opCtx,
- const NamespaceString& nss,
+ StringData ns,
StringData ident,
const CollectionOptions& options) = 0;
virtual std::unique_ptr<SortedDataInterface> getSortedDataInterface(
OperationContext* opCtx,
- const NamespaceString& nss,
const CollectionOptions& collOptions,
StringData ident,
const IndexDescriptor* desc) = 0;
@@ -98,7 +97,7 @@ public:
* back and it is safe to immediately reclaim storage.
*/
virtual Status createRecordStore(OperationContext* opCtx,
- const NamespaceString& nss,
+ StringData ns,
StringData ident,
const CollectionOptions& options,
KeyFormat keyFormat = KeyFormat::Long) = 0;
@@ -119,7 +118,6 @@ public:
}
virtual Status createSortedDataInterface(OperationContext* opCtx,
- const NamespaceString& nss,
const CollectionOptions& collOptions,
StringData ident,
const IndexDescriptor* desc) = 0;
@@ -175,7 +173,7 @@ public:
const NamespaceString& nss,
StringData ident,
const CollectionOptions& options) {
- auto status = createRecordStore(opCtx, nss, ident, options);
+ auto status = createRecordStore(opCtx, nss.ns(), ident, options);
if (status.isOK()) {
return {ErrorCodes::DataModifiedByRepair, "Orphan recovery created a new record store"};
}
diff --git a/src/mongo/db/storage/kv/kv_engine_test_harness.cpp b/src/mongo/db/storage/kv/kv_engine_test_harness.cpp
index 00f128bf12e..90633aa446c 100644
--- a/src/mongo/db/storage/kv/kv_engine_test_harness.cpp
+++ b/src/mongo/db/storage/kv/kv_engine_test_harness.cpp
@@ -161,9 +161,8 @@ TEST_F(KVEngineTestHarness, SimpleRS1) {
std::unique_ptr<RecordStore> rs;
{
auto opCtx = _makeOperationContext(engine);
- ASSERT_OK(
- engine->createRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions()));
- rs = engine->getRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions());
+ ASSERT_OK(engine->createRecordStore(opCtx.get(), ns, ns, CollectionOptions()));
+ rs = engine->getRecordStore(opCtx.get(), ns, ns, CollectionOptions());
ASSERT(rs);
}
@@ -204,9 +203,8 @@ TEST_F(KVEngineTestHarness, Restart1) {
std::unique_ptr<RecordStore> rs;
{
auto opCtx = _makeOperationContext(engine);
- ASSERT_OK(engine->createRecordStore(
- opCtx.get(), NamespaceString(ns), ns, CollectionOptions()));
- rs = engine->getRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions());
+ ASSERT_OK(engine->createRecordStore(opCtx.get(), ns, ns, CollectionOptions()));
+ rs = engine->getRecordStore(opCtx.get(), ns, ns, CollectionOptions());
ASSERT(rs);
}
@@ -230,7 +228,7 @@ TEST_F(KVEngineTestHarness, Restart1) {
{
std::unique_ptr<RecordStore> rs;
auto opCtx = _makeOperationContext(engine);
- rs = engine->getRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions());
+ rs = engine->getRecordStore(opCtx.get(), ns, ns, CollectionOptions());
ASSERT_EQUALS(std::string("abc"), rs->dataFor(opCtx.get(), loc).data());
}
}
@@ -242,7 +240,7 @@ TEST_F(KVEngineTestHarness, SimpleSorted1) {
ASSERT(engine);
std::string ident = "abc";
- NamespaceString nss("mydb.mycoll");
+ auto nss = NamespaceString("mydb.mycoll");
CollectionOptions options;
options.uuid = UUID::gen();
@@ -251,11 +249,12 @@ TEST_F(KVEngineTestHarness, SimpleSorted1) {
{
auto opCtx = _makeOperationContext(engine);
WriteUnitOfWork uow(opCtx.get());
- ASSERT_OK(engine->createRecordStore(opCtx.get(), nss, "catalog", options));
- rs = engine->getRecordStore(opCtx.get(), nss, "catalog", options);
+ ASSERT_OK(engine->createRecordStore(opCtx.get(), "catalog", "catalog", options));
+ rs = engine->getRecordStore(opCtx.get(), "catalog", "catalog", options);
uow.commit();
}
+
std::unique_ptr<Collection> collection;
{
auto opCtx = _makeOperationContext(engine);
@@ -271,8 +270,9 @@ TEST_F(KVEngineTestHarness, SimpleSorted1) {
std::unique_ptr<SortedDataInterface> sorted;
{
auto opCtx = _makeOperationContext(engine);
- ASSERT_OK(engine->createSortedDataInterface(opCtx.get(), nss, options, ident, &desc));
- sorted = engine->getSortedDataInterface(opCtx.get(), nss, options, ident, &desc);
+ ASSERT_OK(
+ engine->createSortedDataInterface(opCtx.get(), CollectionOptions(), ident, &desc));
+ sorted = engine->getSortedDataInterface(opCtx.get(), CollectionOptions(), ident, &desc);
ASSERT(sorted);
}
@@ -345,8 +345,8 @@ TEST_F(KVEngineTestHarness, AllDurableTimestamp) {
options.cappedMaxDocs = -1;
NamespaceString oplogNss("local.oplog.rs");
- ASSERT_OK(engine->createRecordStore(opCtx.get(), oplogNss, "ident", options));
- rs = engine->getRecordStore(opCtx.get(), oplogNss, "ident", options);
+ ASSERT_OK(engine->createRecordStore(opCtx.get(), oplogNss.ns(), "ident", options));
+ rs = engine->getRecordStore(opCtx.get(), oplogNss.ns(), "ident", options);
ASSERT(rs);
}
{
@@ -431,9 +431,8 @@ TEST_F(KVEngineTestHarness, PinningOldestWithAnotherSession) {
std::unique_ptr<RecordStore> rs;
{
auto opCtx = _makeOperationContext(engine);
- ASSERT_OK(
- engine->createRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions()));
- rs = engine->getRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions());
+ ASSERT_OK(engine->createRecordStore(opCtx.get(), ns, ns, CollectionOptions()));
+ rs = engine->getRecordStore(opCtx.get(), ns, ns, CollectionOptions());
ASSERT(rs);
}
@@ -500,9 +499,8 @@ TEST_F(KVEngineTestHarness, AllDurable) {
std::unique_ptr<RecordStore> rs;
{
auto opCtx = _makeOperationContext(engine);
- ASSERT_OK(
- engine->createRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions()));
- rs = engine->getRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions());
+ ASSERT_OK(engine->createRecordStore(opCtx.get(), ns, ns, CollectionOptions()));
+ rs = engine->getRecordStore(opCtx.get(), ns, ns, CollectionOptions());
ASSERT(rs);
}
@@ -593,9 +591,8 @@ TEST_F(KVEngineTestHarness, BasicTimestampSingle) {
std::unique_ptr<RecordStore> rs;
{
auto opCtx = _makeOperationContext(engine);
- ASSERT_OK(
- engine->createRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions()));
- rs = engine->getRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions());
+ ASSERT_OK(engine->createRecordStore(opCtx.get(), ns, ns, CollectionOptions()));
+ rs = engine->getRecordStore(opCtx.get(), ns, ns, CollectionOptions());
ASSERT(rs);
}
@@ -666,9 +663,8 @@ TEST_F(KVEngineTestHarness, BasicTimestampMultiple) {
std::unique_ptr<RecordStore> rs;
{
auto opCtx = _makeOperationContext(engine);
- ASSERT_OK(
- engine->createRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions()));
- rs = engine->getRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions());
+ ASSERT_OK(engine->createRecordStore(opCtx.get(), ns, ns, CollectionOptions()));
+ rs = engine->getRecordStore(opCtx.get(), ns, ns, CollectionOptions());
ASSERT(rs);
}
@@ -726,9 +722,8 @@ DEATH_TEST_REGEX_F(KVEngineTestHarness, SnapshotHidesVisibility, ".*item not fou
std::unique_ptr<RecordStore> rs;
{
auto opCtx = _makeOperationContext(engine);
- ASSERT_OK(
- engine->createRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions()));
- rs = engine->getRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions());
+ ASSERT_OK(engine->createRecordStore(opCtx.get(), ns, ns, CollectionOptions()));
+ rs = engine->getRecordStore(opCtx.get(), ns, ns, CollectionOptions());
ASSERT(rs);
}
@@ -785,10 +780,8 @@ TEST_F(KVEngineTestHarness, SingleReadWithConflictWithOplog) {
std::unique_ptr<RecordStore> oplogRs;
{
auto opCtx = _makeOperationContext(engine);
- ASSERT_OK(
- engine->createRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions()));
- collectionRs =
- engine->getRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions());
+ ASSERT_OK(engine->createRecordStore(opCtx.get(), ns, ns, CollectionOptions()));
+ collectionRs = engine->getRecordStore(opCtx.get(), ns, ns, CollectionOptions());
ASSERT(collectionRs);
CollectionOptions options;
@@ -797,8 +790,8 @@ TEST_F(KVEngineTestHarness, SingleReadWithConflictWithOplog) {
options.cappedMaxDocs = -1;
NamespaceString oplogNss("local.oplog.rs");
- ASSERT_OK(engine->createRecordStore(opCtx.get(), oplogNss, "ident", options));
- oplogRs = engine->getRecordStore(opCtx.get(), oplogNss, "ident", options);
+ ASSERT_OK(engine->createRecordStore(opCtx.get(), oplogNss.ns(), "ident", options));
+ oplogRs = engine->getRecordStore(opCtx.get(), oplogNss.ns(), "ident", options);
ASSERT(oplogRs);
}
@@ -863,9 +856,8 @@ TEST_F(KVEngineTestHarness, PinningOldestTimestampWithReadConflict) {
std::unique_ptr<RecordStore> rs;
{
auto opCtx = _makeOperationContext(engine);
- ASSERT_OK(
- engine->createRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions()));
- rs = engine->getRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions());
+ ASSERT_OK(engine->createRecordStore(opCtx.get(), ns, ns, CollectionOptions()));
+ rs = engine->getRecordStore(opCtx.get(), ns, ns, CollectionOptions());
ASSERT(rs);
}
@@ -910,9 +902,8 @@ DEATH_TEST_REGEX_F(KVEngineTestHarness,
std::unique_ptr<RecordStore> rs;
{
auto opCtx = _makeOperationContext(engine);
- ASSERT_OK(
- engine->createRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions()));
- rs = engine->getRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions());
+ ASSERT_OK(engine->createRecordStore(opCtx.get(), ns, ns, CollectionOptions()));
+ rs = engine->getRecordStore(opCtx.get(), ns, ns, CollectionOptions());
ASSERT(rs);
}
@@ -954,9 +945,8 @@ TEST_F(KVEngineTestHarness, RollingBackToLastStable) {
std::unique_ptr<RecordStore> rs;
{
auto opCtx = _makeOperationContext(engine);
- ASSERT_OK(
- engine->createRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions()));
- rs = engine->getRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions());
+ ASSERT_OK(engine->createRecordStore(opCtx.get(), ns, ns, CollectionOptions()));
+ rs = engine->getRecordStore(opCtx.get(), ns, ns, CollectionOptions());
ASSERT(rs);
}
@@ -1037,9 +1027,8 @@ DEATH_TEST_REGEX_F(KVEngineTestHarness, CommitBehindStable, "Fatal assertion.*39
std::unique_ptr<RecordStore> rs;
{
auto opCtx = _makeOperationContext(engine);
- ASSERT_OK(
- engine->createRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions()));
- rs = engine->getRecordStore(opCtx.get(), NamespaceString(ns), ns, CollectionOptions());
+ ASSERT_OK(engine->createRecordStore(opCtx.get(), ns, ns, CollectionOptions()));
+ rs = engine->getRecordStore(opCtx.get(), ns, ns, CollectionOptions());
ASSERT(rs);
}
@@ -1073,10 +1062,8 @@ TEST_F(DurableCatalogImplTest, Coll1) {
auto clientAndCtx = makeClientAndCtx("opCtx");
auto opCtx = clientAndCtx.opCtx();
WriteUnitOfWork uow(opCtx);
- ASSERT_OK(engine->createRecordStore(
- opCtx, NamespaceString("catalog"), "catalog", CollectionOptions()));
- rs = engine->getRecordStore(
- opCtx, NamespaceString("catalog"), "catalog", CollectionOptions());
+ ASSERT_OK(engine->createRecordStore(opCtx, "catalog", "catalog", CollectionOptions()));
+ rs = engine->getRecordStore(opCtx, "catalog", "catalog", CollectionOptions());
catalog = std::make_unique<DurableCatalogImpl>(rs.get(), false, false, nullptr);
uow.commit();
}
@@ -1127,10 +1114,8 @@ TEST_F(DurableCatalogImplTest, Idx1) {
auto clientAndCtx = makeClientAndCtx("opCtx");
auto opCtx = clientAndCtx.opCtx();
WriteUnitOfWork uow(opCtx);
- ASSERT_OK(engine->createRecordStore(
- opCtx, NamespaceString("catalog"), "catalog", CollectionOptions()));
- rs = engine->getRecordStore(
- opCtx, NamespaceString("catalog"), "catalog", CollectionOptions());
+ ASSERT_OK(engine->createRecordStore(opCtx, "catalog", "catalog", CollectionOptions()));
+ rs = engine->getRecordStore(opCtx, "catalog", "catalog", CollectionOptions());
catalog = std::make_unique<DurableCatalogImpl>(rs.get(), false, false, nullptr);
uow.commit();
}
@@ -1217,10 +1202,8 @@ TEST_F(DurableCatalogImplTest, DirectoryPerDb1) {
auto clientAndCtx = makeClientAndCtx("opCtx");
auto opCtx = clientAndCtx.opCtx();
WriteUnitOfWork uow(opCtx);
- ASSERT_OK(engine->createRecordStore(
- opCtx, NamespaceString("catalog"), "catalog", CollectionOptions()));
- rs = engine->getRecordStore(
- opCtx, NamespaceString("catalog"), "catalog", CollectionOptions());
+ ASSERT_OK(engine->createRecordStore(opCtx, "catalog", "catalog", CollectionOptions()));
+ rs = engine->getRecordStore(opCtx, "catalog", "catalog", CollectionOptions());
catalog = std::make_unique<DurableCatalogImpl>(rs.get(), true, false, nullptr);
uow.commit();
}
@@ -1269,10 +1252,8 @@ TEST_F(DurableCatalogImplTest, Split1) {
auto clientAndCtx = makeClientAndCtx("opCtx");
auto opCtx = clientAndCtx.opCtx();
WriteUnitOfWork uow(opCtx);
- ASSERT_OK(engine->createRecordStore(
- opCtx, NamespaceString("catalog"), "catalog", CollectionOptions()));
- rs = engine->getRecordStore(
- opCtx, NamespaceString("catalog"), "catalog", CollectionOptions());
+ ASSERT_OK(engine->createRecordStore(opCtx, "catalog", "catalog", CollectionOptions()));
+ rs = engine->getRecordStore(opCtx, "catalog", "catalog", CollectionOptions());
catalog = std::make_unique<DurableCatalogImpl>(rs.get(), false, true, nullptr);
uow.commit();
}
@@ -1321,10 +1302,8 @@ TEST_F(DurableCatalogImplTest, DirectoryPerAndSplit1) {
auto clientAndCtx = makeClientAndCtx("opCtx");
auto opCtx = clientAndCtx.opCtx();
WriteUnitOfWork uow(opCtx);
- ASSERT_OK(engine->createRecordStore(
- opCtx, NamespaceString("catalog"), "catalog", CollectionOptions()));
- rs = engine->getRecordStore(
- opCtx, NamespaceString("catalog"), "catalog", CollectionOptions());
+ ASSERT_OK(engine->createRecordStore(opCtx, "catalog", "catalog", CollectionOptions()));
+ rs = engine->getRecordStore(opCtx, "catalog", "catalog", CollectionOptions());
catalog = std::make_unique<DurableCatalogImpl>(rs.get(), true, true, nullptr);
uow.commit();
}
@@ -1383,7 +1362,7 @@ DEATH_TEST_REGEX_F(DurableCatalogImplTest,
ASSERT(engine);
std::string ident = "abc";
- NamespaceString nss("mydb.mycoll");
+ auto nss = NamespaceString("mydb.mycoll");
CollectionOptions options;
options.uuid = UUID::gen();
@@ -1393,8 +1372,8 @@ DEATH_TEST_REGEX_F(DurableCatalogImplTest,
auto clientAndCtx = makeClientAndCtx("opCtx");
auto opCtx = clientAndCtx.opCtx();
WriteUnitOfWork uow(opCtx);
- ASSERT_OK(engine->createRecordStore(opCtx, NamespaceString("catalog"), "catalog", options));
- rs = engine->getRecordStore(opCtx, NamespaceString("catalog"), "catalog", options);
+ ASSERT_OK(engine->createRecordStore(opCtx, "catalog", "catalog", options));
+ rs = engine->getRecordStore(opCtx, "catalog", "catalog", options);
uow.commit();
}
@@ -1416,8 +1395,8 @@ DEATH_TEST_REGEX_F(DurableCatalogImplTest,
{
auto clientAndCtx = makeClientAndCtx("opCtx");
auto opCtx = clientAndCtx.opCtx();
- ASSERT_OK(engine->createSortedDataInterface(opCtx, nss, CollectionOptions(), ident, &desc));
- sorted = engine->getSortedDataInterface(opCtx, nss, CollectionOptions(), ident, &desc);
+ ASSERT_OK(engine->createSortedDataInterface(opCtx, CollectionOptions(), ident, &desc));
+ sorted = engine->getSortedDataInterface(opCtx, CollectionOptions(), ident, &desc);
ASSERT(sorted);
}
}
diff --git a/src/mongo/db/storage/kv/kv_engine_timestamps_test.cpp b/src/mongo/db/storage/kv/kv_engine_timestamps_test.cpp
index 83f9b251ddd..0fc5665be32 100644
--- a/src/mongo/db/storage/kv/kv_engine_timestamps_test.cpp
+++ b/src/mongo/db/storage/kv/kv_engine_timestamps_test.cpp
@@ -204,8 +204,8 @@ public:
auto op = makeOperation();
WriteUnitOfWork wuow(op);
std::string ns = "a.b";
- ASSERT_OK(engine->createRecordStore(op, NamespaceString(ns), ns, CollectionOptions()));
- rs = engine->getRecordStore(op, NamespaceString(ns), ns, CollectionOptions());
+ ASSERT_OK(engine->createRecordStore(op, ns, ns, CollectionOptions()));
+ rs = engine->getRecordStore(op, ns, ns, CollectionOptions());
ASSERT(rs);
}
diff --git a/src/mongo/db/storage/recovery_unit.h b/src/mongo/db/storage/recovery_unit.h
index a67d1f090f5..5dcfec7a548 100644
--- a/src/mongo/db/storage/recovery_unit.h
+++ b/src/mongo/db/storage/recovery_unit.h
@@ -732,6 +732,10 @@ public:
return _getState();
}
+ void setMustBeTimestamped() {
+ _mustBeTimestamped = true;
+ }
+
void setNoEvictionAfterRollback() {
_noEvictionAfterRollback = true;
}
@@ -795,6 +799,8 @@ protected:
*/
void _executeRollbackHandlers();
+ bool _mustBeTimestamped = false;
+
bool _noEvictionAfterRollback = false;
AbandonSnapshotMode _abandonSnapshotMode = AbandonSnapshotMode::kAbort;
diff --git a/src/mongo/db/storage/storage_engine_impl.cpp b/src/mongo/db/storage/storage_engine_impl.cpp
index 5f5e0de5a9d..bbcf0d11ce2 100644
--- a/src/mongo/db/storage/storage_engine_impl.cpp
+++ b/src/mongo/db/storage/storage_engine_impl.cpp
@@ -72,7 +72,7 @@ MONGO_FAIL_POINT_DEFINE(pauseTimestampMonitor);
MONGO_FAIL_POINT_DEFINE(setMinVisibleForAllCollectionsToOldestOnStartup);
namespace {
-const std::string kCatalogInfo = "_mdb_catalog";
+const std::string catalogInfo = "_mdb_catalog";
const auto kCatalogLogLevel = logv2::LogSeverity::Debug(2);
} // namespace
@@ -116,13 +116,13 @@ StorageEngineImpl::StorageEngineImpl(OperationContext* opCtx,
}
void StorageEngineImpl::loadCatalog(OperationContext* opCtx, LastShutdownState lastShutdownState) {
- bool catalogExists = _engine->hasIdent(opCtx, kCatalogInfo);
+ bool catalogExists = _engine->hasIdent(opCtx, catalogInfo);
if (_options.forRepair && catalogExists) {
auto repairObserver = StorageRepairObserver::get(getGlobalServiceContext());
invariant(repairObserver->isIncomplete());
LOGV2(22246, "Repairing catalog metadata");
- Status status = _engine->repairIdent(opCtx, kCatalogInfo);
+ Status status = _engine->repairIdent(opCtx, catalogInfo);
if (status.code() == ErrorCodes::DataModifiedByRepair) {
LOGV2_WARNING(22264, "Catalog data modified by repair", "error"_attr = status);
@@ -136,8 +136,8 @@ void StorageEngineImpl::loadCatalog(OperationContext* opCtx, LastShutdownState l
if (!catalogExists) {
WriteUnitOfWork uow(opCtx);
- auto status = _engine->createRecordStore(
- opCtx, NamespaceString(kCatalogInfo), kCatalogInfo, CollectionOptions());
+ auto status =
+ _engine->createRecordStore(opCtx, catalogInfo, catalogInfo, CollectionOptions());
// BadValue is usually caused by invalid configuration string.
// We still fassert() but without a stack trace.
@@ -148,8 +148,8 @@ void StorageEngineImpl::loadCatalog(OperationContext* opCtx, LastShutdownState l
uow.commit();
}
- _catalogRecordStore = _engine->getRecordStore(
- opCtx, NamespaceString(kCatalogInfo), kCatalogInfo, CollectionOptions());
+ _catalogRecordStore =
+ _engine->getRecordStore(opCtx, catalogInfo, catalogInfo, CollectionOptions());
if (shouldLog(::mongo::logv2::LogComponent::kStorageRecovery, kCatalogLogLevel)) {
LOGV2_FOR_RECOVERY(4615631, kCatalogLogLevel.toInt(), "loadCatalog:");
_dumpCatalog(opCtx);
@@ -376,7 +376,7 @@ void StorageEngineImpl::_initCollection(OperationContext* opCtx,
// repaired. This also ensures that if we try to use it, it will blow up.
rs = nullptr;
} else {
- rs = _engine->getRecordStore(opCtx, nss, ident, md->options);
+ rs = _engine->getRecordStore(opCtx, nss.ns(), ident, md->options);
invariant(rs);
}
@@ -481,7 +481,7 @@ bool StorageEngineImpl::_handleInternalIdent(OperationContext* opCtx,
// When starting up after a clean shutdown and resumable index builds are supported, find the
// internal idents that contain the relevant information to resume each index build and recover
// the state.
- auto rs = _engine->getRecordStore(opCtx, NamespaceString(""), ident, CollectionOptions());
+ auto rs = _engine->getRecordStore(opCtx, "", ident, CollectionOptions());
auto cursor = rs->getCursor(opCtx);
auto record = cursor->next();
@@ -555,7 +555,7 @@ StatusWith<StorageEngine::ReconcileResult> StorageEngineImpl::reconcileCatalogAn
{
std::vector<std::string> vec = _engine->getAllIdents(opCtx);
engineIdents.insert(vec.begin(), vec.end());
- engineIdents.erase(kCatalogInfo);
+ engineIdents.erase(catalogInfo);
}
LOGV2_FOR_RECOVERY(4615633, 2, "Reconciling collection and index idents.");
@@ -1014,7 +1014,7 @@ StorageEngineImpl::makeTemporaryRecordStoreForResumableIndexBuild(OperationConte
std::unique_ptr<TemporaryRecordStore> StorageEngineImpl::makeTemporaryRecordStoreFromExistingIdent(
OperationContext* opCtx, StringData ident) {
- auto rs = _engine->getRecordStore(opCtx, NamespaceString(""), ident, CollectionOptions());
+ auto rs = _engine->getRecordStore(opCtx, "", ident, CollectionOptions());
return std::make_unique<DeferredDropRecordStore>(std::move(rs), this);
}
diff --git a/src/mongo/db/storage/storage_engine_test_fixture.h b/src/mongo/db/storage/storage_engine_test_fixture.h
index 266052614a7..16017aca24c 100644
--- a/src/mongo/db/storage/storage_engine_test_fixture.h
+++ b/src/mongo/db/storage/storage_engine_test_fixture.h
@@ -105,7 +105,7 @@ public:
Status createCollTable(OperationContext* opCtx, NamespaceString collName) {
const std::string identName = "collection-" + collName.ns();
return _storageEngine->getEngine()->createRecordStore(
- opCtx, collName, identName, CollectionOptions());
+ opCtx, collName.ns(), identName, CollectionOptions());
}
Status dropIndexTable(OperationContext* opCtx, NamespaceString nss, std::string indexName) {
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp
index cd9a25c2930..4ad647c49bb 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp
@@ -147,8 +147,7 @@ StatusWith<std::string> WiredTigerIndex::generateCreateString(
const std::string& sysIndexConfig,
const std::string& collIndexConfig,
const NamespaceString& collectionNamespace,
- const IndexDescriptor& desc,
- bool isLogged) {
+ const IndexDescriptor& desc) {
str::stream ss;
// Separate out a prefix and suffix in the default string. User configuration will override
@@ -203,7 +202,10 @@ StatusWith<std::string> WiredTigerIndex::generateCreateString(
// Index metadata
ss << generateAppMetadataString(desc);
- if (isLogged) {
+
+ bool replicatedWrites = getGlobalReplSettings().usingReplSets() ||
+ repl::ReplSettings::shouldRecoverFromOplogAsStandalone();
+ if (WiredTigerUtil::useTableLogging(collectionNamespace, replicatedWrites)) {
ss << "log=(enabled=true)";
} else {
ss << "log=(enabled=false)";
@@ -236,10 +238,9 @@ WiredTigerIndex::WiredTigerIndex(OperationContext* ctx,
StringData ident,
KeyFormat rsKeyFormat,
const IndexDescriptor* desc,
- bool isLogged,
bool isReadOnly)
: SortedDataInterface(ident,
- _handleVersionInfo(ctx, uri, desc, isLogged, isReadOnly),
+ _handleVersionInfo(ctx, uri, desc, isReadOnly),
Ordering::make(desc->keyPattern()),
rsKeyFormat),
_uri(uri),
@@ -247,8 +248,7 @@ WiredTigerIndex::WiredTigerIndex(OperationContext* ctx,
_desc(desc),
_indexName(desc->indexName()),
_keyPattern(desc->keyPattern()),
- _collation(desc->collation()),
- _isLogged(isLogged) {}
+ _collation(desc->collation()) {}
NamespaceString WiredTigerIndex::getCollectionNamespace(OperationContext* opCtx) const {
return _desc->getEntry()->getNSSFromCatalog(opCtx);
@@ -636,7 +636,6 @@ StatusWith<bool> WiredTigerIndex::_checkDups(OperationContext* opCtx,
KeyString::Version WiredTigerIndex::_handleVersionInfo(OperationContext* ctx,
const std::string& uri,
const IndexDescriptor* desc,
- bool isLogged,
bool isReadOnly) {
auto version = WiredTigerUtil::checkApplicationMetadataFormatVersion(
ctx, uri, kMinimumIndexVersion, kMaximumIndexVersion);
@@ -665,7 +664,12 @@ KeyString::Version WiredTigerIndex::_handleVersionInfo(OperationContext* ctx,
}
if (!isReadOnly) {
- uassertStatusOK(WiredTigerUtil::setTableLogging(ctx, uri, isLogged));
+ bool replicatedWrites = getGlobalReplSettings().usingReplSets() ||
+ repl::ReplSettings::shouldRecoverFromOplogAsStandalone();
+ bool useTableLogging = !replicatedWrites ||
+ WiredTigerUtil::useTableLogging(desc->getEntry()->getNSSFromCatalog(ctx),
+ replicatedWrites);
+ uassertStatusOK(WiredTigerUtil::setTableLogging(ctx, uri, useTableLogging));
}
/*
@@ -1487,10 +1491,8 @@ WiredTigerIndexUnique::WiredTigerIndexUnique(OperationContext* ctx,
StringData ident,
KeyFormat rsKeyFormat,
const IndexDescriptor* desc,
- bool isLogged,
bool isReadOnly)
- : WiredTigerIndex(ctx, uri, ident, rsKeyFormat, desc, isLogged, isReadOnly),
- _partial(desc->isPartial()) {
+ : WiredTigerIndex(ctx, uri, ident, rsKeyFormat, desc, isReadOnly), _partial(desc->isPartial()) {
// _id indexes must use WiredTigerIdIndex
invariant(!isIdIndex());
// All unique indexes should be in the timestamp-safe format version as of version 4.2.
@@ -1576,9 +1578,8 @@ WiredTigerIdIndex::WiredTigerIdIndex(OperationContext* ctx,
const std::string& uri,
StringData ident,
const IndexDescriptor* desc,
- bool isLogged,
bool isReadOnly)
- : WiredTigerIndex(ctx, uri, ident, KeyFormat::Long, desc, isLogged, isReadOnly) {
+ : WiredTigerIndex(ctx, uri, ident, KeyFormat::Long, desc, isReadOnly) {
invariant(isIdIndex());
}
@@ -1808,9 +1809,8 @@ WiredTigerIndexStandard::WiredTigerIndexStandard(OperationContext* ctx,
StringData ident,
KeyFormat rsKeyFormat,
const IndexDescriptor* desc,
- bool isLogged,
bool isReadOnly)
- : WiredTigerIndex(ctx, uri, ident, rsKeyFormat, desc, isLogged, isReadOnly) {}
+ : WiredTigerIndex(ctx, uri, ident, rsKeyFormat, desc, isReadOnly) {}
std::unique_ptr<SortedDataInterface::Cursor> WiredTigerIndexStandard::newCursor(
OperationContext* opCtx, bool forward) const {
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_index.h b/src/mongo/db/storage/wiredtiger/wiredtiger_index.h
index 5a94980c22c..fa6fd010af6 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_index.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_index.h
@@ -102,8 +102,7 @@ public:
const std::string& sysIndexConfig,
const std::string& collIndexConfig,
const NamespaceString& collectionNamespace,
- const IndexDescriptor& desc,
- bool isLogged);
+ const IndexDescriptor& desc);
/**
* Creates a WiredTiger table suitable for implementing a MongoDB index.
@@ -126,7 +125,6 @@ public:
StringData ident,
KeyFormat rsKeyFormat,
const IndexDescriptor* desc,
- bool isLogged,
bool readOnly);
virtual Status insert(OperationContext* opCtx,
@@ -232,7 +230,6 @@ protected:
KeyString::Version _handleVersionInfo(OperationContext* ctx,
const std::string& uri,
const IndexDescriptor* desc,
- bool isLogged,
bool isReadOnly);
RecordId _decodeRecordIdAtEnd(const void* buffer, size_t size);
@@ -253,7 +250,6 @@ protected:
const std::string _indexName;
const BSONObj _keyPattern;
const BSONObj _collation;
- const bool _isLogged;
};
class WiredTigerIndexUnique : public WiredTigerIndex {
@@ -263,7 +259,6 @@ public:
StringData ident,
KeyFormat rsKeyFormat,
const IndexDescriptor* desc,
- bool isLogged,
bool readOnly = false);
std::unique_ptr<SortedDataInterface::Cursor> newCursor(OperationContext* opCtx,
@@ -305,7 +300,6 @@ public:
const std::string& uri,
StringData ident,
const IndexDescriptor* desc,
- bool isLogged,
bool readOnly = false);
std::unique_ptr<Cursor> newCursor(OperationContext* opCtx,
@@ -357,7 +351,6 @@ public:
StringData ident,
KeyFormat rsKeyFormat,
const IndexDescriptor* desc,
- bool isLogged,
bool readOnly = false);
std::unique_ptr<SortedDataInterface::Cursor> newCursor(OperationContext* opCtx,
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
index 3cb2aca26a3..3702c16613b 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
@@ -1431,21 +1431,15 @@ void WiredTigerKVEngine::setSortedDataInterfaceExtraOptions(const std::string& o
}
Status WiredTigerKVEngine::createRecordStore(OperationContext* opCtx,
- const NamespaceString& nss,
+ StringData ns,
StringData ident,
const CollectionOptions& options,
KeyFormat keyFormat) {
_ensureIdentPath(ident);
WiredTigerSession session(_conn);
- StatusWith<std::string> result =
- WiredTigerRecordStore::generateCreateString(_canonicalName,
- nss,
- ident,
- options,
- _rsOptions,
- keyFormat,
- WiredTigerUtil::useTableLogging(nss));
+ StatusWith<std::string> result = WiredTigerRecordStore::generateCreateString(
+ _canonicalName, ns, ident, options, _rsOptions, keyFormat);
if (options.clusteredIndex) {
// A clustered collection requires both CollectionOptions.clusteredIndex and
@@ -1466,7 +1460,7 @@ Status WiredTigerKVEngine::createRecordStore(OperationContext* opCtx,
LOGV2_DEBUG(22331,
2,
"WiredTigerKVEngine::createRecordStore ns: {namespace} uri: {uri} config: {config}",
- logAttrs(nss),
+ logAttrs(NamespaceString(ns)),
"uri"_attr = uri,
"config"_attr = config);
return wtRCToStatus(s->create(s, uri.c_str(), config.c_str()), s);
@@ -1541,7 +1535,7 @@ Status WiredTigerKVEngine::recoverOrphanedIdent(OperationContext* opCtx,
"namespace"_attr = nss,
"uuid"_attr = options.uuid);
- status = createRecordStore(opCtx, nss, ident, options);
+ status = createRecordStore(opCtx, nss.ns(), ident, options);
if (!status.isOK()) {
return status;
}
@@ -1586,21 +1580,12 @@ Status WiredTigerKVEngine::recoverOrphanedIdent(OperationContext* opCtx,
}
std::unique_ptr<RecordStore> WiredTigerKVEngine::getRecordStore(OperationContext* opCtx,
- const NamespaceString& nss,
+ StringData ns,
StringData ident,
const CollectionOptions& options) {
- bool isLogged;
- if (nss.size() == 0) {
- fassert(8423353, ident.startsWith("internal-"));
- isLogged = !getGlobalReplSettings().usingReplSets() &&
- !repl::ReplSettings::shouldRecoverFromOplogAsStandalone();
- } else {
- isLogged = WiredTigerUtil::useTableLogging(nss);
- }
-
WiredTigerRecordStore::Params params;
- params.nss = nss;
+ params.ns = ns;
params.ident = ident.toString();
params.engineName = _canonicalName;
params.isCapped = options.capped;
@@ -1609,14 +1594,13 @@ std::unique_ptr<RecordStore> WiredTigerKVEngine::getRecordStore(OperationContext
// overwrites.
params.overwrite = options.clusteredIndex ? false : true;
params.isEphemeral = _ephemeral;
- params.isLogged = isLogged;
params.cappedCallback = nullptr;
params.sizeStorer = _sizeStorer.get();
params.isReadOnly = _readOnly;
params.tracksSizeAdjustments = true;
params.forceUpdateWithFullDocument = options.timeseries != boost::none;
- if (nss.isOplog()) {
+ if (NamespaceString::oplog(ns)) {
// The oplog collection must have a size provided.
invariant(options.cappedSize > 0);
params.oplogMaxSize = options.cappedSize;
@@ -1645,7 +1629,6 @@ string WiredTigerKVEngine::_uri(StringData ident) const {
}
Status WiredTigerKVEngine::createSortedDataInterface(OperationContext* opCtx,
- const NamespaceString& nss,
const CollectionOptions& collOptions,
StringData ident,
const IndexDescriptor* desc) {
@@ -1659,13 +1642,12 @@ Status WiredTigerKVEngine::createSortedDataInterface(OperationContext* opCtx,
.str();
}
// Some unittests use a OperationContextNoop that can't support such lookups.
- StatusWith<std::string> result =
- WiredTigerIndex::generateCreateString(_canonicalName,
- _indexOptions,
- collIndexOptions,
- nss,
- *desc,
- WiredTigerUtil::useTableLogging(nss));
+ auto ns = collOptions.uuid
+ ? *CollectionCatalog::get(opCtx)->lookupNSSByUUID(opCtx, *collOptions.uuid)
+ : NamespaceString();
+
+ StatusWith<std::string> result = WiredTigerIndex::generateCreateString(
+ _canonicalName, _indexOptions, collIndexOptions, ns, *desc);
if (!result.isOK()) {
return result.getStatus();
}
@@ -1714,33 +1696,21 @@ Status WiredTigerKVEngine::dropSortedDataInterface(OperationContext* opCtx, Stri
std::unique_ptr<SortedDataInterface> WiredTigerKVEngine::getSortedDataInterface(
OperationContext* opCtx,
- const NamespaceString& nss,
const CollectionOptions& collOptions,
StringData ident,
const IndexDescriptor* desc) {
if (desc->isIdIndex()) {
invariant(!collOptions.clusteredIndex);
- return std::make_unique<WiredTigerIdIndex>(
- opCtx, _uri(ident), ident, desc, WiredTigerUtil::useTableLogging(nss), _readOnly);
+ return std::make_unique<WiredTigerIdIndex>(opCtx, _uri(ident), ident, desc, _readOnly);
}
auto keyFormat = (collOptions.clusteredIndex) ? KeyFormat::String : KeyFormat::Long;
if (desc->unique()) {
- return std::make_unique<WiredTigerIndexUnique>(opCtx,
- _uri(ident),
- ident,
- keyFormat,
- desc,
- WiredTigerUtil::useTableLogging(nss),
- _readOnly);
+ return std::make_unique<WiredTigerIndexUnique>(
+ opCtx, _uri(ident), ident, keyFormat, desc, _readOnly);
}
- return std::make_unique<WiredTigerIndexStandard>(opCtx,
- _uri(ident),
- ident,
- keyFormat,
- desc,
- WiredTigerUtil::useTableLogging(nss),
- _readOnly);
+ return std::make_unique<WiredTigerIndexStandard>(
+ opCtx, _uri(ident), ident, keyFormat, desc, _readOnly);
}
std::unique_ptr<RecordStore> WiredTigerKVEngine::makeTemporaryRecordStore(OperationContext* opCtx,
@@ -1751,16 +1721,8 @@ std::unique_ptr<RecordStore> WiredTigerKVEngine::makeTemporaryRecordStore(Operat
_ensureIdentPath(ident);
WiredTigerSession wtSession(_conn);
- // We don't log writes to temporary record stores.
- const bool isLogged = false;
- StatusWith<std::string> swConfig =
- WiredTigerRecordStore::generateCreateString(_canonicalName,
- NamespaceString("") /* internal table */,
- ident,
- CollectionOptions(),
- _rsOptions,
- keyFormat,
- isLogged);
+ StatusWith<std::string> swConfig = WiredTigerRecordStore::generateCreateString(
+ _canonicalName, "" /* internal table */, ident, CollectionOptions(), _rsOptions, keyFormat);
uassertStatusOK(swConfig.getStatus());
std::string config = swConfig.getValue();
@@ -1775,14 +1737,13 @@ std::unique_ptr<RecordStore> WiredTigerKVEngine::makeTemporaryRecordStore(Operat
uassertStatusOK(wtRCToStatus(session->create(session, uri.c_str(), config.c_str()), session));
WiredTigerRecordStore::Params params;
- params.nss = NamespaceString("");
+ params.ns = "";
params.ident = ident.toString();
params.engineName = _canonicalName;
params.isCapped = false;
params.keyFormat = keyFormat;
params.overwrite = true;
params.isEphemeral = _ephemeral;
- params.isLogged = isLogged;
params.cappedCallback = nullptr;
// Temporary collections do not need to persist size information to the size storer.
params.sizeStorer = nullptr;
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h
index 7360c65f3ec..297946d5615 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h
@@ -137,13 +137,13 @@ public:
RecoveryUnit* newRecoveryUnit() override;
Status createRecordStore(OperationContext* opCtx,
- const NamespaceString& ns,
+ StringData ns,
StringData ident,
const CollectionOptions& options,
KeyFormat keyFormat = KeyFormat::Long) override;
std::unique_ptr<RecordStore> getRecordStore(OperationContext* opCtx,
- const NamespaceString& nss,
+ StringData ns,
StringData ident,
const CollectionOptions& options) override;
@@ -152,14 +152,12 @@ public:
KeyFormat keyFormat) override;
Status createSortedDataInterface(OperationContext* opCtx,
- const NamespaceString& ns,
const CollectionOptions& collOptions,
StringData ident,
const IndexDescriptor* desc) override;
std::unique_ptr<SortedDataInterface> getSortedDataInterface(
OperationContext* opCtx,
- const NamespaceString& nss,
const CollectionOptions& collOptions,
StringData ident,
const IndexDescriptor* desc) override;
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp
index 9917d95e0f2..82b12b2f244 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp
@@ -38,14 +38,12 @@
#include <memory>
#include "mongo/base/init.h"
-#include "mongo/db/global_settings.h"
#include "mongo/db/operation_context_noop.h"
#include "mongo/db/repl/repl_settings.h"
#include "mongo/db/repl/replication_coordinator_mock.h"
#include "mongo/db/service_context.h"
#include "mongo/db/service_context_test_fixture.h"
#include "mongo/db/storage/checkpointer.h"
-#include "mongo/db/storage/wiredtiger/wiredtiger_global_options.h"
#include "mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h"
#include "mongo/db/storage/wiredtiger/wiredtiger_record_store.h"
#include "mongo/logv2/log.h"
@@ -61,13 +59,9 @@ class WiredTigerKVHarnessHelper : public KVHarnessHelper {
public:
WiredTigerKVHarnessHelper(ServiceContext* svcCtx, bool forRepair = false)
: _dbpath("wt-kv-harness"), _forRepair(forRepair), _engine(makeEngine()) {
- // Faitfhully simulate being in replica set mode for timestamping tests which requires
- // parity for journaling settings.
- repl::ReplSettings replSettings;
- replSettings.setReplSetString("i am a replica set");
- setGlobalReplSettings(replSettings);
repl::ReplicationCoordinator::set(
- svcCtx, std::make_unique<repl::ReplicationCoordinatorMock>(svcCtx, replSettings));
+ svcCtx,
+ std::make_unique<repl::ReplicationCoordinatorMock>(svcCtx, repl::ReplSettings()));
_engine->notifyStartupComplete();
}
@@ -88,16 +82,13 @@ public:
private:
std::unique_ptr<WiredTigerKVEngine> makeEngine() {
- // Use a small journal for testing to account for the unlikely event that the underlying
- // filesystem does not support fast allocation of a file of zeros.
- std::string extraStrings = "log=(file_max=1m,prealloc=false)";
return std::make_unique<WiredTigerKVEngine>(kWiredTigerEngineName,
_dbpath.path(),
_cs.get(),
- extraStrings,
+ "",
1,
0,
- true,
+ false,
false,
_forRepair,
false);
@@ -142,8 +133,9 @@ TEST_F(WiredTigerKVEngineRepairTest, OrphanedDataFilesCanBeRecovered) {
CollectionOptions defaultCollectionOptions;
std::unique_ptr<RecordStore> rs;
- ASSERT_OK(_engine->createRecordStore(opCtxPtr.get(), nss, ident, defaultCollectionOptions));
- rs = _engine->getRecordStore(opCtxPtr.get(), nss, ident, defaultCollectionOptions);
+ ASSERT_OK(
+ _engine->createRecordStore(opCtxPtr.get(), nss.ns(), ident, defaultCollectionOptions));
+ rs = _engine->getRecordStore(opCtxPtr.get(), nss.ns(), ident, defaultCollectionOptions);
ASSERT(rs);
RecordId loc;
@@ -199,8 +191,9 @@ TEST_F(WiredTigerKVEngineRepairTest, UnrecoverableOrphanedDataFilesAreRebuilt) {
CollectionOptions defaultCollectionOptions;
std::unique_ptr<RecordStore> rs;
- ASSERT_OK(_engine->createRecordStore(opCtxPtr.get(), nss, ident, defaultCollectionOptions));
- rs = _engine->getRecordStore(opCtxPtr.get(), nss, ident, defaultCollectionOptions);
+ ASSERT_OK(
+ _engine->createRecordStore(opCtxPtr.get(), nss.ns(), ident, defaultCollectionOptions));
+ rs = _engine->getRecordStore(opCtxPtr.get(), nss.ns(), ident, defaultCollectionOptions);
ASSERT(rs);
RecordId loc;
@@ -248,7 +241,7 @@ TEST_F(WiredTigerKVEngineRepairTest, UnrecoverableOrphanedDataFilesAreRebuilt) {
boost::filesystem::path corruptFile = (dataFilePath->string() + ".corrupt");
ASSERT(boost::filesystem::exists(corruptFile));
- rs = _engine->getRecordStore(opCtxPtr.get(), nss, ident, defaultCollectionOptions);
+ rs = _engine->getRecordStore(opCtxPtr.get(), nss.ns(), ident, defaultCollectionOptions);
RecordData data;
ASSERT_FALSE(rs->findRecord(opCtxPtr.get(), loc, &data));
#endif
@@ -370,7 +363,8 @@ TEST_F(WiredTigerKVEngineTest, IdentDrop) {
CollectionOptions defaultCollectionOptions;
std::unique_ptr<RecordStore> rs;
- ASSERT_OK(_engine->createRecordStore(opCtxPtr.get(), nss, ident, defaultCollectionOptions));
+ ASSERT_OK(
+ _engine->createRecordStore(opCtxPtr.get(), nss.ns(), ident, defaultCollectionOptions));
const boost::optional<boost::filesystem::path> dataFilePath =
_engine->getDataFilePathForIdent(ident);
@@ -382,7 +376,8 @@ TEST_F(WiredTigerKVEngineTest, IdentDrop) {
// Because the underlying file was not removed, it will be renamed out of the way by WiredTiger
// when creating a new table with the same ident.
- ASSERT_OK(_engine->createRecordStore(opCtxPtr.get(), nss, ident, defaultCollectionOptions));
+ ASSERT_OK(
+ _engine->createRecordStore(opCtxPtr.get(), nss.ns(), ident, defaultCollectionOptions));
const boost::filesystem::path renamedFilePath = dataFilePath->generic_string() + ".1";
ASSERT(boost::filesystem::exists(*dataFilePath));
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
index a715ca4b2c0..c5ad83cfbb5 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
@@ -773,12 +773,11 @@ private:
// static
StatusWith<std::string> WiredTigerRecordStore::generateCreateString(
const std::string& engineName,
- const NamespaceString& nss,
+ StringData ns,
StringData ident,
const CollectionOptions& options,
StringData extraStrings,
- KeyFormat keyFormat,
- bool loggingEnabled) {
+ KeyFormat keyFormat) {
// Separate out a prefix and suffix in the default string. User configuration will
// override values in the prefix, but not values in the suffix.
@@ -792,7 +791,7 @@ StatusWith<std::string> WiredTigerRecordStore::generateCreateString(
ss << "split_pct=90,";
ss << "leaf_value_max=64MB,";
if (TestingProctor::instance().isEnabled()) {
- if (nss.isOplog()) {
+ if (NamespaceString(ns).isOplog()) {
// For the above clauses we do not assert any particular `write_timestamp_usage`. In
// particular for the oplog, WT removes all timestamp information. There's nothing in
// MDB's control to assert against.
@@ -801,7 +800,8 @@ StatusWith<std::string> WiredTigerRecordStore::generateCreateString(
ident.startsWith("internal-") ||
// TODO (SERVER-60753): Remove special handling for index build during recovery. This
// includes the following _mdb_catalog ident.
- nss == NamespaceString::kIndexBuildEntryNamespace || ident.startsWith("_mdb_catalog")) {
+ ns == NamespaceString::kIndexBuildEntryNamespace.ns() ||
+ ident.startsWith("_mdb_catalog")) {
ss << "write_timestamp_usage=mixed_mode,";
} else {
ss << "write_timestamp_usage=ordered,";
@@ -825,8 +825,7 @@ StatusWith<std::string> WiredTigerRecordStore::generateCreateString(
}
ss << ",";
- ss << WiredTigerCustomizationHooks::get(getGlobalServiceContext())
- ->getTableCreateConfig(nss.ns());
+ ss << WiredTigerCustomizationHooks::get(getGlobalServiceContext())->getTableCreateConfig(ns);
ss << extraStrings << ",";
@@ -837,6 +836,7 @@ StatusWith<std::string> WiredTigerRecordStore::generateCreateString(
ss << customOptions.getValue();
+ NamespaceString nss(ns);
if (nss.isOplog()) {
// force file for oplog
ss << "type=file,";
@@ -865,12 +865,17 @@ StatusWith<std::string> WiredTigerRecordStore::generateCreateString(
// Record store metadata
ss << ",app_metadata=(formatVersion=" << kCurrentRecordStoreVersion;
- if (nss.isOplog()) {
+ if (NamespaceString::oplog(ns)) {
ss << ",oplogKeyExtractionVersion=1";
}
ss << ")";
- if (loggingEnabled) {
+ bool replicatedWrites = getGlobalReplSettings().usingReplSets() ||
+ repl::ReplSettings::shouldRecoverFromOplogAsStandalone();
+
+ // Do not journal writes when 'ns' is an empty string, which is the case for internal-only
+ // temporary tables.
+ if (ns.size() && WiredTigerUtil::useTableLogging(NamespaceString(ns), replicatedWrites)) {
ss << ",log=(enabled=true)";
} else {
ss << ",log=(enabled=false)";
@@ -882,7 +887,7 @@ StatusWith<std::string> WiredTigerRecordStore::generateCreateString(
WiredTigerRecordStore::WiredTigerRecordStore(WiredTigerKVEngine* kvEngine,
OperationContext* ctx,
Params params)
- : RecordStore(params.nss.ns(), params.ident),
+ : RecordStore(params.ns, params.ident),
_uri(WiredTigerKVEngine::kTableUriPrefix + params.ident),
_tableId(WiredTigerSession::genTableId()),
_engineName(params.engineName),
@@ -890,8 +895,12 @@ WiredTigerRecordStore::WiredTigerRecordStore(WiredTigerKVEngine* kvEngine,
_keyFormat(params.keyFormat),
_overwrite(params.overwrite),
_isEphemeral(params.isEphemeral),
- _isLogged(params.isLogged),
- _isOplog(params.nss.isOplog()),
+ _isLogged(!isTemp() &&
+ WiredTigerUtil::useTableLogging(
+ NamespaceString(ns()),
+ getGlobalReplSettings().usingReplSets() ||
+ repl::ReplSettings::shouldRecoverFromOplogAsStandalone())),
+ _isOplog(NamespaceString::oplog(params.ns)),
_forceUpdateWithFullDocument(params.forceUpdateWithFullDocument),
_oplogMaxSize(params.oplogMaxSize),
_cappedCallback(params.cappedCallback),
@@ -912,7 +921,7 @@ WiredTigerRecordStore::WiredTigerRecordStore(WiredTigerKVEngine* kvEngine,
}
if (_oplogMaxSize) {
- invariant(_isOplog, str::stream() << "Namespace " << params.nss);
+ invariant(_isOplog, str::stream() << "Namespace " << params.ns);
}
Status versionStatus = WiredTigerUtil::checkApplicationMetadataFormatVersion(
@@ -1095,11 +1104,6 @@ RecordData WiredTigerRecordStore::_getData(const WiredTigerCursor& cursor) const
bool WiredTigerRecordStore::findRecord(OperationContext* opCtx,
const RecordId& id,
RecordData* out) const {
- if (_isOplog) {
- // This optimized findRecord implementation does not apply oplog visibility rules. Use the
- // base class implementation which uses a cursor that guarantees the proper semantics.
- return RecordStore::findRecord(opCtx, id, out);
- }
dassert(opCtx->lockState()->isReadLocked());
WiredTigerCursor curwrap(_uri, _tableId, true, opCtx);
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h
index 7630cc0900b..7109b2cfc7c 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.h
@@ -95,22 +95,20 @@ public:
* fail with the constructed configuration string.
*/
static StatusWith<std::string> generateCreateString(const std::string& engineName,
- const NamespaceString& nss,
+ StringData ns,
StringData ident,
const CollectionOptions& options,
StringData extraStrings,
- KeyFormat keyFormat,
- bool loggingEnabled);
+ KeyFormat keyFormat);
struct Params {
- NamespaceString nss;
+ StringData ns;
std::string ident;
std::string engineName;
bool isCapped;
KeyFormat keyFormat;
bool overwrite;
bool isEphemeral;
- bool isLogged;
boost::optional<int64_t> oplogMaxSize;
CappedCallback* cappedCallback;
WiredTigerSizeStorer* sizeStorer;
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp
index a2d9c5f7e99..c02a8ca55c2 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp
@@ -1082,16 +1082,9 @@ TEST(WiredTigerRecordStoreTest, ClusteredRecordStore) {
ASSERT(opCtx.get());
const std::string ns = "testRecordStore";
- const NamespaceString nss(ns);
const std::string uri = WiredTigerKVEngine::kTableUriPrefix + ns;
- const StatusWith<std::string> result =
- WiredTigerRecordStore::generateCreateString(kWiredTigerEngineName,
- nss,
- "",
- CollectionOptions(),
- "",
- KeyFormat::String,
- WiredTigerUtil::useTableLogging(nss));
+ const StatusWith<std::string> result = WiredTigerRecordStore::generateCreateString(
+ kWiredTigerEngineName, ns, "", CollectionOptions(), "", KeyFormat::String);
ASSERT_TRUE(result.isOK());
const std::string config = result.getValue();
@@ -1105,14 +1098,13 @@ TEST(WiredTigerRecordStoreTest, ClusteredRecordStore) {
}
WiredTigerRecordStore::Params params;
- params.nss = nss;
+ params.ns = ns;
params.ident = ns;
params.engineName = kWiredTigerEngineName;
params.isCapped = false;
params.keyFormat = KeyFormat::String;
params.overwrite = false;
params.isEphemeral = false;
- params.isLogged = WiredTigerUtil::useTableLogging(nss);
params.cappedCallback = nullptr;
params.sizeStorer = nullptr;
params.tracksSizeAdjustments = true;
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test_harness.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test_harness.cpp
index b05808b8cbe..ecfcda26448 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test_harness.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test_harness.cpp
@@ -34,24 +34,16 @@
namespace mongo {
-namespace {
-std::string _testLoggingSettings(std::string extraStrings) {
- // Use a small journal for testing to account for the unlikely event that the underlying
- // filesystem does not support fast allocation of a file of zeros.
- return extraStrings + ",log=(file_max=1m,prealloc=false)";
-}
-} // namespace
-
WiredTigerHarnessHelper::WiredTigerHarnessHelper(StringData extraStrings)
: _dbpath("wt_test"),
_lockerNoopClientObserverRegisterer(getServiceContext()),
_engine(kWiredTigerEngineName,
_dbpath.path(),
&_cs,
- _testLoggingSettings(extraStrings.toString()),
+ extraStrings.toString(),
1,
0,
- true,
+ false,
false,
false,
false) {
@@ -67,16 +59,9 @@ std::unique_ptr<RecordStore> WiredTigerHarnessHelper::newRecordStore(
OperationContextNoop opCtx(ru);
std::string uri = WiredTigerKVEngine::kTableUriPrefix + ns;
StringData ident = ns;
- NamespaceString nss(ns);
StatusWith<std::string> result = WiredTigerRecordStore::generateCreateString(
- kWiredTigerEngineName,
- NamespaceString(ns),
- ident,
- collOptions,
- "",
- keyFormat,
- WiredTigerUtil::useTableLogging(NamespaceString(ns)));
+ kWiredTigerEngineName, ns, ident, collOptions, "", keyFormat);
ASSERT_TRUE(result.isOK());
std::string config = result.getValue();
@@ -88,14 +73,13 @@ std::unique_ptr<RecordStore> WiredTigerHarnessHelper::newRecordStore(
}
WiredTigerRecordStore::Params params;
- params.nss = nss;
+ params.ns = ns;
params.ident = ident.toString();
params.engineName = kWiredTigerEngineName;
params.isCapped = collOptions.capped ? true : false;
params.keyFormat = collOptions.clusteredIndex ? KeyFormat::String : KeyFormat::Long;
params.overwrite = collOptions.clusteredIndex ? false : true;
params.isEphemeral = false;
- params.isLogged = WiredTigerUtil::useTableLogging(nss);
params.cappedCallback = nullptr;
params.sizeStorer = nullptr;
params.isReadOnly = false;
@@ -124,15 +108,9 @@ std::unique_ptr<RecordStore> WiredTigerHarnessHelper::newOplogRecordStoreNoInit(
CollectionOptions options;
options.capped = true;
- const NamespaceString oplogNss = NamespaceString::kRsOplogNamespace;
- StatusWith<std::string> result =
- WiredTigerRecordStore::generateCreateString(kWiredTigerEngineName,
- oplogNss,
- ident,
- options,
- "",
- KeyFormat::Long,
- WiredTigerUtil::useTableLogging(oplogNss));
+ const std::string ns = NamespaceString::kRsOplogNamespace.toString();
+ StatusWith<std::string> result = WiredTigerRecordStore::generateCreateString(
+ kWiredTigerEngineName, ns, ident, options, "", KeyFormat::Long);
ASSERT_TRUE(result.isOK());
std::string config = result.getValue();
@@ -144,7 +122,7 @@ std::unique_ptr<RecordStore> WiredTigerHarnessHelper::newOplogRecordStoreNoInit(
}
WiredTigerRecordStore::Params params;
- params.nss = oplogNss;
+ params.ns = ns;
params.ident = ident;
params.engineName = kWiredTigerEngineName;
params.isCapped = true;
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp
index ca2e5d8c1b4..4fe60f56356 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp
@@ -477,6 +477,10 @@ void WiredTigerRecoveryUnit::_txnClose(bool commit) {
end, FMT_STRING(durableTimestampFmtString), _durableTimestamp.asULL());
}
+ if (_mustBeTimestamped) {
+ invariant(_isTimestamped);
+ }
+
*end = '\0';
wtRet = s->commit_transaction(s, conf.data());
@@ -531,6 +535,7 @@ void WiredTigerRecoveryUnit::_txnClose(bool commit) {
_isOplogReader = false;
_oplogVisibleTs = boost::none;
_orderedCommit = true; // Default value is true; we assume all writes are ordered.
+ _mustBeTimestamped = false;
}
Status WiredTigerRecoveryUnit::majorityCommittedSnapshotAvailable() const {
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp
index da700a414bb..d82d74fa50d 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit_test.cpp
@@ -79,16 +79,9 @@ public:
virtual std::unique_ptr<RecordStore> createRecordStore(OperationContext* opCtx,
const std::string& ns) final {
std::string ident = ns;
- NamespaceString nss(ns);
std::string uri = WiredTigerKVEngine::kTableUriPrefix + ns;
- StatusWith<std::string> result =
- WiredTigerRecordStore::generateCreateString(kWiredTigerEngineName,
- nss,
- ident,
- CollectionOptions(),
- "",
- KeyFormat::Long,
- WiredTigerUtil::useTableLogging(nss));
+ StatusWith<std::string> result = WiredTigerRecordStore::generateCreateString(
+ kWiredTigerEngineName, ns, ident, CollectionOptions(), "", KeyFormat::Long);
ASSERT_TRUE(result.isOK());
std::string config = result.getValue();
@@ -102,14 +95,13 @@ public:
}
WiredTigerRecordStore::Params params;
- params.nss = nss;
+ params.ns = ns;
params.ident = ident;
params.engineName = kWiredTigerEngineName;
params.isCapped = false;
params.keyFormat = KeyFormat::Long;
params.overwrite = true;
params.isEphemeral = false;
- params.isLogged = WiredTigerUtil::useTableLogging(nss);
params.cappedCallback = nullptr;
params.sizeStorer = nullptr;
params.tracksSizeAdjustments = true;
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp
index f4cdc403149..807146ed32d 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp
@@ -79,7 +79,6 @@ public:
std::unique_ptr<SortedDataInterface> newIdIndexSortedDataInterface() final {
std::string ns = "test.wt";
- NamespaceString nss(ns);
OperationContextNoop opCtx(newRecoveryUnit().release());
BSONObj spec = BSON("key" << BSON("_id" << 1) << "name"
@@ -87,26 +86,24 @@ public:
<< "v" << static_cast<int>(IndexDescriptor::kLatestIndexVersion)
<< "unique" << true);
- auto collection = std::make_unique<CollectionMock>(nss);
+ auto collection = std::make_unique<CollectionMock>(NamespaceString(ns));
IndexDescriptor desc("", spec);
invariant(desc.isIdIndex());
- const bool isLogged = false;
StatusWith<std::string> result = WiredTigerIndex::generateCreateString(
- kWiredTigerEngineName, "", "", nss, desc, isLogged);
+ kWiredTigerEngineName, "", "", NamespaceString(ns), desc);
ASSERT_OK(result.getStatus());
string uri = "table:" + ns;
invariant(Status::OK() == WiredTigerIndex::Create(&opCtx, uri, result.getValue()));
- return std::make_unique<WiredTigerIdIndex>(&opCtx, uri, "" /* ident */, &desc, isLogged);
+ return std::make_unique<WiredTigerIdIndex>(&opCtx, uri, "" /* ident */, &desc);
}
std::unique_ptr<mongo::SortedDataInterface> newSortedDataInterface(bool unique,
bool partial,
KeyFormat keyFormat) final {
std::string ns = "test.wt";
- NamespaceString nss(ns);
OperationContextNoop opCtx(newRecoveryUnit().release());
BSONObj spec = BSON("key" << BSON("a" << 1) << "name"
@@ -121,27 +118,23 @@ public:
spec = spec.addField(partialBSON.firstElement());
}
- auto collection = std::make_unique<CollectionMock>(nss);
+ auto collection = std::make_unique<CollectionMock>(NamespaceString(ns));
IndexDescriptor& desc = _descriptors.emplace_back("", spec);
StatusWith<std::string> result = WiredTigerIndex::generateCreateString(
- kWiredTigerEngineName, "", "", nss, desc, WiredTigerUtil::useTableLogging(nss));
+ kWiredTigerEngineName, "", "", NamespaceString(ns), desc);
ASSERT_OK(result.getStatus());
string uri = "table:" + ns;
invariant(Status::OK() == WiredTigerIndex::Create(&opCtx, uri, result.getValue()));
if (unique) {
- return std::make_unique<WiredTigerIndexUnique>(&opCtx,
- uri,
- "" /* ident */,
- keyFormat,
- &desc,
- WiredTigerUtil::useTableLogging(nss));
+ return std::make_unique<WiredTigerIndexUnique>(
+ &opCtx, uri, "" /* ident */, keyFormat, &desc);
}
return std::make_unique<WiredTigerIndexStandard>(
- &opCtx, uri, "" /* ident */, keyFormat, &desc, WiredTigerUtil::useTableLogging(nss));
+ &opCtx, uri, "" /* ident */, keyFormat, &desc);
}
std::unique_ptr<RecoveryUnit> newRecoveryUnit() final {
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_standard_record_store_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_standard_record_store_test.cpp
index 5db15a1eb2e..a1d0b854e91 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_standard_record_store_test.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_standard_record_store_test.cpp
@@ -106,7 +106,7 @@ TEST(WiredTigerRecordStoreTest, SizeStorer1) {
{
ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
WiredTigerRecordStore::Params params;
- params.nss = NamespaceString("a.b");
+ params.ns = "a.b"_sd;
params.ident = ident;
params.engineName = kWiredTigerEngineName;
params.isCapped = false;
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp
index 3605eb90a76..31317e7d1f1 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp
@@ -42,7 +42,6 @@
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/db/concurrency/temporarily_unavailable_exception.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
-#include "mongo/db/global_settings.h"
#include "mongo/db/server_options_general_gen.h"
#include "mongo/db/snapshot_window_options_gen.h"
#include "mongo/db/storage/storage_file_util.h"
@@ -840,26 +839,19 @@ void WiredTigerUtil::resetTableLoggingInfo() {
_tableLoggingInfo = TableLoggingInfo();
}
-bool WiredTigerUtil::useTableLogging(const NamespaceString& nss) {
- // We only turn off logging in the case of:
- // 1) Replication is enabled (the typical deployment), or
- // 2) We're running as a standalone with recoverFromOplogAsStandalone=true
- const bool journalWritesBecauseStandalone = !getGlobalReplSettings().usingReplSets() &&
- !repl::ReplSettings::shouldRecoverFromOplogAsStandalone();
- if (journalWritesBecauseStandalone) {
+bool WiredTigerUtil::useTableLogging(NamespaceString ns, bool replEnabled) {
+ if (!replEnabled) {
+ // All tables on standalones are logged.
return true;
}
- // Don't make assumptions if there is no namespace string.
- invariant(nss.size() > 0);
-
// Of the replica set configurations:
- if (!nss.isLocal()) {
+ if (ns.db() != "local") {
// All replicated collections are not logged.
return false;
}
- if (nss.coll() == "replset.minvalid") {
+ if (ns.coll() == "replset.minvalid") {
// Of local collections, this is derived from the state of the data and therefore
// not logged.
return false;
@@ -985,6 +977,8 @@ Status WiredTigerUtil::setTableLogging(OperationContext* opCtx, const std::strin
Status WiredTigerUtil::_setTableLogging(WiredTigerSessionCache* sessionCache,
const std::string& uri,
bool on) {
+ auto engine = sessionCache->getKVEngine();
+
const std::string setting = on ? "log=(enabled=true)" : "log=(enabled=false)";
// This method does some "weak" parsing to see if the table is in the expected logging
@@ -1014,9 +1008,7 @@ Status WiredTigerUtil::_setTableLogging(WiredTigerSessionCache* sessionCache,
LOGV2_DEBUG(
22432, 1, "Changing table logging settings", "uri"_attr = uri, "loggingEnabled"_attr = on);
- // Only alter the metadata once we're sure that we need to change the table settings, since
- // WT_SESSION::alter may return EBUSY and require taking a checkpoint to make progress.
- auto status = sessionCache->getKVEngine()->alterMetadata(uri, setting);
+ auto status = engine->alterMetadata(uri, setting);
if (!status.isOK()) {
LOGV2_FATAL(50756,
"Failed to update log setting",
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_util.h b/src/mongo/db/storage/wiredtiger/wiredtiger_util.h
index 83bcd4e0293..6c537828b24 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_util.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_util.h
@@ -317,7 +317,7 @@ public:
static void resetTableLoggingInfo();
- static bool useTableLogging(const NamespaceString& nss);
+ static bool useTableLogging(NamespaceString ns, bool replEnabled);
static Status setTableLogging(OperationContext* opCtx, const std::string& uri, bool on);