summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp')
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp147
1 files changed, 19 insertions, 128 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
index ed1ec49e90f..2c5a6ed5559 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
@@ -472,12 +472,6 @@ WiredTigerKVEngine::WiredTigerKVEngine(const std::string& canonicalName,
ss << WiredTigerUtil::generateRestoreConfig() << ",";
}
- // If we've requested an ephemeral instance we store everything into memory instead of backing
- // it onto disk. Logging is not supported in this instance, thus we also have to disable it.
- if (_ephemeral) {
- ss << "in_memory=true,log=(enabled=false),";
- }
-
string config = ss.str();
LOGV2(22315, "Opening WiredTiger", "config"_attr = config);
auto startTime = Date_t::now();
@@ -725,6 +719,7 @@ void WiredTigerKVEngine::_openWiredTiger(const std::string& path, const std::str
void WiredTigerKVEngine::cleanShutdown() {
LOGV2(22317, "WiredTigerKVEngine shutting down");
+ WiredTigerUtil::resetTableLoggingInfo();
if (!_conn) {
return;
@@ -1064,30 +1059,6 @@ std::deque<std::string> getUniqueFiles(const std::vector<std::string>& files,
return result;
}
-/**
- * Normalizes ident names with and without 'directoryPerDb' and 'wiredTigerDirectoryForIndexes'
- * mode.
- *
- * The durable catalog can return idents in four forms:
- * - <db_name>/<collection|index>/<ident_identifier>
- * - directoryPerDb + wiredTigerDirectoryForIndexes
- * - <db_name>/<ident_name>
- * - directoryPerDb
- * - <collection|index>/<ident_identifier>
- * - wiredTigerDirectoryForIndexes
- * - <ident_name>
- * - default, no options enabled
- *
- * ident_identifier: <counter>-<random number>
- * ident_name: <collection|index>-<ident_identifier>
- *
- * This function trims the leading directory names leaving only the ident's unique identifier.
- */
-inline std::string getIdentStem(const std::string& ident) {
- boost::filesystem::path identPath(ident);
- return identPath.stem().string();
-}
-
class StreamingCursorImpl : public StorageEngine::StreamingCursor {
public:
StreamingCursorImpl() = delete;
@@ -1197,22 +1168,11 @@ private:
int wtRet;
bool fileUnchangedFlag = false;
if (!_wtBackup->dupCursor) {
- size_t attempt = 0;
- do {
- wtRet = _session->open_cursor(
- _session, nullptr, _wtBackup->cursor, config.c_str(), &_wtBackup->dupCursor);
-
- if (wtRet == EBUSY) {
- logAndBackoff(8927900,
- ::mongo::logv2::LogComponent::kStorage,
- logv2::LogSeverity::Debug(1),
- ++attempt,
- "Opening duplicate backup cursor returned EBUSY, retrying",
- "config"_attr = config);
- } else if (wtRet != 0) {
- return wtRCToStatus(wtRet, _session);
- }
- } while (wtRet == EBUSY);
+ wtRet = (_session)->open_cursor(
+ _session, nullptr, _wtBackup->cursor, config.c_str(), &_wtBackup->dupCursor);
+ if (wtRet != 0) {
+ return wtRCToStatus(wtRet, _session);
+ }
fileUnchangedFlag = true;
}
@@ -1345,14 +1305,11 @@ WiredTigerKVEngine::beginNonBlockingBackup(OperationContext* opCtx,
for (const DurableCatalog::Entry& e : catalogEntries) {
// Populate the collection ident with its namespace and UUID.
UUID uuid = catalog->getMetaData(opCtx, e.catalogId)->options.uuid.get();
- std::string collectionIdent = getIdentStem(e.ident);
- _wtBackup.identToNamespaceAndUUIDMap.emplace(collectionIdent,
- std::make_pair(e.nss, uuid));
+ _wtBackup.identToNamespaceAndUUIDMap.emplace(e.ident, std::make_pair(e.nss, uuid));
// Populate the collection's index idents with the collection's namespace and UUID.
std::vector<std::string> idxIdents = catalog->getIndexIdents(opCtx, e.catalogId);
- for (const std::string& idxIdentFull : idxIdents) {
- std::string idxIdent = getIdentStem(idxIdentFull);
+ for (const std::string& idxIdent : idxIdents) {
_wtBackup.identToNamespaceAndUUIDMap.emplace(idxIdent, std::make_pair(e.nss, uuid));
}
}
@@ -1441,15 +1398,10 @@ void WiredTigerKVEngine::syncSizeInfo(bool sync) const {
if (!_sizeStorer)
return;
- while (true) {
- try {
- return _sizeStorer->flush(sync);
- } catch (const WriteConflictException&) {
- if (!sync) {
- // ignore, we'll try again later.
- return;
- }
- }
+ try {
+ _sizeStorer->flush(sync);
+ } catch (const WriteConflictException&) {
+ // ignore, we'll try again later.
}
}
@@ -1897,8 +1849,8 @@ Status WiredTigerKVEngine::dropIdent(RecoveryUnit* ru,
WiredTigerSession session(_conn);
- int ret =
- session.getSession()->drop(session.getSession(), uri.c_str(), "checkpoint_wait=false");
+ int ret = session.getSession()->drop(
+ session.getSession(), uri.c_str(), "force,checkpoint_wait=false");
LOGV2_DEBUG(22338, 1, "WT drop", "uri"_attr = uri, "ret"_attr = ret);
if (ret == EBUSY) {
@@ -1911,16 +1863,11 @@ Status WiredTigerKVEngine::dropIdent(RecoveryUnit* ru,
return Status::OK();
}
- if (DurableCatalog::isCollectionIdent(ident)) {
- _sizeStorer->remove(uri);
- }
-
if (onDrop) {
onDrop();
}
if (ret == ENOENT) {
- // Ident doesn't exist, it is effectively dropped.
return Status::OK();
}
@@ -1940,7 +1887,7 @@ void WiredTigerKVEngine::dropIdentForImport(OperationContext* opCtx, StringData
// cursor is open. In short, using "checkpoint_wait=false" and "lock_wait=true" means that we
// can potentially be waiting for a short period of time for WT_SESSION::drop() to run, but
// would rather get EBUSY than wait a long time for a checkpoint to complete.
- const std::string config = "checkpoint_wait=false,lock_wait=true,remove_files=false";
+ const std::string config = "force=true,checkpoint_wait=false,lock_wait=true,remove_files=false";
int ret = 0;
size_t attempt = 0;
do {
@@ -1961,10 +1908,6 @@ void WiredTigerKVEngine::dropIdentForImport(OperationContext* opCtx, StringData
"config"_attr = config,
"ret"_attr = ret);
} while (ret == EBUSY);
- if (ret == ENOENT) {
- // If the ident doesn't exist then it has already been dropped.
- return;
- }
invariantWTOK(ret, session.getSession());
}
@@ -2041,17 +1984,14 @@ void WiredTigerKVEngine::dropSomeQueuedIdents() {
_identToDrop.pop_front();
}
int ret = session.getSession()->drop(
- session.getSession(), identToDrop.uri.c_str(), "checkpoint_wait=false");
+ session.getSession(), identToDrop.uri.c_str(), "force,checkpoint_wait=false");
LOGV2_DEBUG(22340, 1, "WT queued drop", "uri"_attr = identToDrop.uri, "ret"_attr = ret);
if (ret == EBUSY) {
stdx::lock_guard<Latch> lk(_identToDropMutex);
_identToDrop.push_back(std::move(identToDrop));
} else {
- if (ret != ENOENT) {
- // Ident doesn't exist, it is effectively dropped. The error is safe to ignore.
- invariantWTOK(ret, session.getSession());
- }
+ invariantWTOK(ret, session.getSession());
if (identToDrop.callback) {
identToDrop.callback();
}
@@ -2063,26 +2003,7 @@ bool WiredTigerKVEngine::supportsDirectoryPerDB() const {
return true;
}
-void WiredTigerKVEngine::_checkpoint(WT_SESSION* session, bool useTimestamp) {
- _currentCheckpointIteration.fetchAndAdd(1);
- if (useTimestamp) {
- invariantWTOK(session->checkpoint(session, "use_timestamp=true"), session);
- } else {
- invariantWTOK(session->checkpoint(session, "use_timestamp=false"), session);
- }
- auto checkpointedIteration = _finishedCheckpointIteration.fetchAndAdd(1);
- LOGV2_FOR_RECOVERY(8097402,
- 2,
- "Finished checkpoint, updated iteration counter",
- "checkpointIteration"_attr = checkpointedIteration);
-}
-
void WiredTigerKVEngine::_checkpoint(WT_SESSION* session) {
- // Ephemeral WiredTiger instances cannot do a checkpoint to disk as there is no disk backing
- // the data.
- if (_ephemeral) {
- return;
- }
// TODO: SERVER-64507: Investigate whether we can smartly rely on one checkpointer if two or
// more threads checkpoint at the same time.
stdx::lock_guard lk(_checkpointMutex);
@@ -2118,7 +2039,7 @@ void WiredTigerKVEngine::_checkpoint(WT_SESSION* session) {
// Third, stableTimestamp >= initialDataTimestamp: Take stable checkpoint. Steady state
// case.
if (initialDataTimestamp.asULL() <= 1) {
- _checkpoint(session, /*useTimestamp=*/false);
+ invariantWTOK(session->checkpoint(session, "use_timestamp=false"), session);
LOGV2_FOR_RECOVERY(5576602,
2,
"Completed unstable checkpoint.",
@@ -2139,7 +2060,7 @@ void WiredTigerKVEngine::_checkpoint(WT_SESSION* session) {
"stableTimestamp"_attr = stableTimestamp,
"oplogNeededForRollback"_attr = toString(oplogNeededForRollback));
- _checkpoint(session, /*useTimestamp=*/true);
+ invariantWTOK(session->checkpoint(session, "use_timestamp=true"), session);
if (oplogNeededForRollback.isOK()) {
// Now that the checkpoint is durable, publish the oplog needed to recover from it.
@@ -2159,12 +2080,6 @@ void WiredTigerKVEngine::checkpoint() {
return _checkpoint(s);
}
-void WiredTigerKVEngine::forceCheckpoint(bool useStableTimestamp) {
- UniqueWiredTigerSession session = _sessionCache->getSession();
- WT_SESSION* s = session->getSession();
- return _checkpoint(s, useStableTimestamp);
-}
-
bool WiredTigerKVEngine::hasIdent(OperationContext* opCtx, StringData ident) const {
return _hasUri(WiredTigerRecoveryUnit::get(opCtx)->getSession()->getSession(), _uri(ident));
}
@@ -2509,9 +2424,6 @@ StatusWith<Timestamp> WiredTigerKVEngine::recoverToStableTimestamp(OperationCont
"initialDataTimestamp"_attr = initialDataTimestamp);
int ret = 0;
- // Shut down the cache before rollback and restart afterwards.
- _sessionCache->shuttingDown();
-
// The rollback_to_stable operation requires all open cursors to be closed or reset before the
// call, otherwise EBUSY will be returned. Occasionally, there could be an operation that hasn't
// been killed yet, such as the CappedInsertNotifier for a yielded oplog getMore. We will retry
@@ -2545,9 +2457,6 @@ StatusWith<Timestamp> WiredTigerKVEngine::recoverToStableTimestamp(OperationCont
_sizeStorer = std::make_unique<WiredTigerSizeStorer>(_conn, _sizeStorerUri, _readOnly);
- // SERVER-85167: restart the cache after resetting the size storer.
- _sessionCache->restart();
-
return {stableTimestamp};
}
@@ -2837,22 +2746,4 @@ Status WiredTigerKVEngine::reconfigureLogging() {
return wtRCToStatus(_conn->reconfigure(_conn, verboseConfig.c_str()), nullptr);
}
-KeyFormat WiredTigerKVEngine::getKeyFormat(OperationContext* opCtx, StringData ident) const {
-
- const std::string wtTableConfig =
- uassertStatusOK(WiredTigerUtil::getMetadataCreate(opCtx, "table:{}"_format(ident)));
- return wtTableConfig.find("key_format=u") != string::npos ? KeyFormat::String : KeyFormat::Long;
-}
-
-BSONObj WiredTigerKVEngine::getSanitizedStorageOptionsForSecondaryReplication(
- const BSONObj& options) const {
-
- // Skip inMemory storage engine, encryption at rest only applies to storage backed engine.
- if (_ephemeral) {
- return options;
- }
-
- return WiredTigerUtil::getSanitizedStorageOptionsForSecondaryReplication(options);
-}
-
} // namespace mongo