summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2022-08-26 07:36:10 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-08-26 09:50:30 +0000
commitd05a7e1e952cd109506a71a116d9aac6e96c74fa (patch)
tree043c4d135f5660663f54585385fbd2e61474a081 /src/mongo
parent4490f18b1c16f2e89395b85f876b1aa69dcfa884 (diff)
downloadmongo-r6.0.2-rc0.tar.gz
SERVER-68925 Reintroduce check table logging settings at startupr6.0.2-rc0
(cherry picked from commit 994562a9c82fd89549ac8ee0861eb9f10509d32c)
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp1
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp4
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp169
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_util.h16
4 files changed, 5 insertions, 185 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
index 2c5a6ed5559..00b8f6e0309 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
@@ -719,7 +719,6 @@ void WiredTigerKVEngine::_openWiredTiger(const std::string& path, const std::str
void WiredTigerKVEngine::cleanShutdown() {
LOGV2(22317, "WiredTigerKVEngine shutting down");
- WiredTigerUtil::resetTableLoggingInfo();
if (!_conn) {
return;
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..0101172b81b 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp
@@ -66,15 +66,11 @@ public:
_fastClockSource = std::make_unique<SystemClockSource>();
_sessionCache = new WiredTigerSessionCache(_conn, _fastClockSource.get());
-
- WiredTigerUtil::notifyStartupComplete();
}
~WiredTigerIndexHarnessHelper() final {
delete _sessionCache;
_conn->close(_conn, nullptr);
-
- WiredTigerUtil::resetTableLoggingInfo();
}
std::unique_ptr<SortedDataInterface> newIdIndexSortedDataInterface() final {
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp
index de31ec10751..7991c6b2738 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp
@@ -54,7 +54,6 @@
#include "mongo/db/storage/wiredtiger/wiredtiger_session_cache.h"
#include "mongo/logv2/log.h"
#include "mongo/util/assert_util.h"
-#include "mongo/util/fail_point.h"
#include "mongo/util/processinfo.h"
#include "mongo/util/scopeguard.h"
#include "mongo/util/static_immortal.h"
@@ -66,8 +65,6 @@
namespace mongo {
-MONGO_FAIL_POINT_DEFINE(crashAfterUpdatingFirstTableLoggingSettings);
-
namespace {
const std::string kTableChecksFileName = "_wt_table_checks";
@@ -75,41 +72,6 @@ const std::string kTableExtension = ".wt";
const std::string kWiredTigerBackupFile = "WiredTiger.backup";
/**
- * Returns true if the 'kTableChecksFileName' file exists in the dbpath.
- *
- * Must be called before createTableChecksFile() or removeTableChecksFile() to get accurate results.
- */
-bool hasPreviouslyIncompleteTableChecks() {
- auto path = boost::filesystem::path(storageGlobalParams.dbpath) /
- boost::filesystem::path(kTableChecksFileName);
-
- return boost::filesystem::exists(path);
-}
-
-/**
- * Creates the 'kTableChecksFileName' file in the dbpath.
- */
-void createTableChecksFile() {
- auto path = boost::filesystem::path(storageGlobalParams.dbpath) /
- boost::filesystem::path(kTableChecksFileName);
-
- boost::filesystem::ofstream fileStream(path);
- fileStream << "This file indicates that a WiredTiger table check operation is in progress or "
- "incomplete."
- << std::endl;
- if (fileStream.fail()) {
- LOGV2_FATAL_NOTRACE(4366400,
- "Failed to write to file",
- "file"_attr = path.generic_string(),
- "error"_attr = errnoWithDescription());
- }
- fileStream.close();
-
- fassertNoTrace(4366401, fsyncFile(path));
- fassertNoTrace(4366402, fsyncParentDirectory(path));
-}
-
-/**
* Removes the 'kTableChecksFileName' file in the dbpath, if it exists.
*/
void removeTableChecksFile() {
@@ -159,10 +121,6 @@ void setTableWriteTimestampAssertion(WiredTigerSessionCache* sessionCache,
using std::string;
-Mutex WiredTigerUtil::_tableLoggingInfoMutex =
- MONGO_MAKE_LATCH("WiredTigerUtil::_tableLoggingInfoMutex");
-WiredTigerUtil::TableLoggingInfo WiredTigerUtil::_tableLoggingInfo;
-
bool wasRollbackReasonCachePressure(WT_SESSION* session) {
if (session) {
const auto reason = session->get_rollback_reason(session);
@@ -826,20 +784,7 @@ int WiredTigerUtil::verifyTable(OperationContext* opCtx,
}
void WiredTigerUtil::notifyStartupComplete() {
- {
- stdx::lock_guard<Latch> lk(_tableLoggingInfoMutex);
- invariant(_tableLoggingInfo.isInitializing);
- _tableLoggingInfo.isInitializing = false;
- }
-
- if (!storageGlobalParams.readOnly) {
- removeTableChecksFile();
- }
-}
-
-void WiredTigerUtil::resetTableLoggingInfo() {
- stdx::lock_guard<Latch> lk(_tableLoggingInfoMutex);
- _tableLoggingInfo = TableLoggingInfo();
+ removeTableChecksFile();
}
bool WiredTigerUtil::useTableLogging(const NamespaceString& nss) {
@@ -873,120 +818,16 @@ bool WiredTigerUtil::useTableLogging(const NamespaceString& nss) {
}
Status WiredTigerUtil::setTableLogging(OperationContext* opCtx, const std::string& uri, bool on) {
- // Try to close as much as possible to avoid EBUSY errors.
- WiredTigerRecoveryUnit::get(opCtx)->getSession()->closeAllCursors(uri);
- WiredTigerSessionCache* sessionCache = WiredTigerRecoveryUnit::get(opCtx)->getSessionCache();
- sessionCache->closeAllCursors(uri);
-
- invariant(!storageGlobalParams.readOnly);
- stdx::lock_guard<Latch> lk(_tableLoggingInfoMutex);
-
- // Update the table logging settings regardless if we're no longer starting up the process.
- if (!_tableLoggingInfo.isInitializing) {
- return _setTableLogging(sessionCache, uri, on);
- }
-
- // During the start up process, the table logging settings are checked for each table to verify
- // that they are set appropriately. We can speed this process up by assuming that the logging
- // setting is identical for each table.
- // We cross reference the logging settings for the first table and if it isn't correctly set, we
- // change the logging settings for all tables during start up.
- // In the event that the server wasn't shutdown cleanly, the logging settings will be modified
- // for all tables as a safety precaution, or if repair mode is running.
- if (_tableLoggingInfo.isFirstTable && hasPreviouslyIncompleteTableChecks()) {
- _tableLoggingInfo.hasPreviouslyIncompleteTableChecks = true;
- }
-
if (gWiredTigerSkipTableLoggingChecksOnStartup) {
- if (_tableLoggingInfo.hasPreviouslyIncompleteTableChecks) {
- LOGV2_FATAL_NOTRACE(
- 5548300,
- "Cannot use the 'wiredTigerSkipTableLoggingChecksOnStartup' startup parameter when "
- "there are previously incomplete table checks");
- }
-
- // Only log this warning once.
- if (_tableLoggingInfo.isFirstTable) {
- _tableLoggingInfo.isFirstTable = false;
- LOGV2_WARNING_OPTIONS(
- 5548301,
- {logv2::LogTag::kStartupWarnings},
- "Skipping table logging checks for all existing WiredTiger tables on startup",
- "wiredTigerSkipTableLoggingChecksOnStartup"_attr =
- gWiredTigerSkipTableLoggingChecksOnStartup);
- }
-
LOGV2_DEBUG(5548302, 1, "Skipping table logging check", "uri"_attr = uri);
return Status::OK();
}
- if (storageGlobalParams.repair || _tableLoggingInfo.hasPreviouslyIncompleteTableChecks) {
- if (_tableLoggingInfo.isFirstTable) {
- _tableLoggingInfo.isFirstTable = false;
- if (!_tableLoggingInfo.hasPreviouslyIncompleteTableChecks) {
- createTableChecksFile();
- }
-
- LOGV2(4366405,
- "Modifying the table logging settings for all existing WiredTiger tables",
- "loggingEnabled"_attr = on,
- "repair"_attr = storageGlobalParams.repair,
- "hasPreviouslyIncompleteTableChecks"_attr =
- _tableLoggingInfo.hasPreviouslyIncompleteTableChecks);
- }
-
- return _setTableLogging(sessionCache, uri, on);
- }
-
- if (!_tableLoggingInfo.isFirstTable) {
- if (_tableLoggingInfo.changeTableLogging) {
- return _setTableLogging(sessionCache, uri, on);
- }
-
- // The table logging settings do not need to be modified.
- return Status::OK();
- }
-
- invariant(_tableLoggingInfo.isFirstTable);
- invariant(!_tableLoggingInfo.hasPreviouslyIncompleteTableChecks);
-
- // When repair or a forced modification to the table logging settings isn't running, check that
- // the first table is the catalog.
- invariant(uri == "table:_mdb_catalog", str::stream() << "First table checked was: " << uri);
- _tableLoggingInfo.isFirstTable = false;
-
- // Check if the first tables logging settings need to be modified.
- const std::string setting = on ? "log=(enabled=true)" : "log=(enabled=false)";
- const std::string existingMetadata = getMetadataCreate(opCtx, uri).getValue();
- if (existingMetadata.find(setting) != std::string::npos) {
- // The table is running with the expected logging settings.
- LOGV2(4366408,
- "No table logging settings modifications are required for existing WiredTiger tables",
- "loggingEnabled"_attr = on);
- return Status::OK();
- }
-
- // The first table is running with the incorrect logging settings. All tables will need to have
- // their logging settings modified.
- _tableLoggingInfo.changeTableLogging = true;
- createTableChecksFile();
-
- LOGV2(4366406,
- "Modifying the table logging settings for all existing WiredTiger tables",
- "loggingEnabled"_attr = on);
-
- Status status = _setTableLogging(sessionCache, uri, on);
-
- if (MONGO_unlikely(crashAfterUpdatingFirstTableLoggingSettings.shouldFail())) {
- LOGV2_FATAL_NOTRACE(
- 4366407, "Crashing due to 'crashAfterUpdatingFirstTableLoggingSettings' fail point");
- }
- return status;
-}
+ // Try to close as much as possible to avoid EBUSY errors.
+ WiredTigerRecoveryUnit::get(opCtx)->getSession()->closeAllCursors(uri);
+ WiredTigerSessionCache* sessionCache = WiredTigerRecoveryUnit::get(opCtx)->getSessionCache();
+ sessionCache->closeAllCursors(uri);
-Status WiredTigerUtil::_setTableLogging(WiredTigerSessionCache* sessionCache,
- const std::string& uri,
- bool on) {
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
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_util.h b/src/mongo/db/storage/wiredtiger/wiredtiger_util.h
index 83bcd4e0293..dbca93e6bc6 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_util.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_util.h
@@ -315,8 +315,6 @@ public:
static void notifyStartupComplete();
- static void resetTableLoggingInfo();
-
static bool useTableLogging(const NamespaceString& nss);
static Status setTableLogging(OperationContext* opCtx, const std::string& uri, bool on);
@@ -341,20 +339,6 @@ private:
*/
template <typename T>
static T _castStatisticsValue(uint64_t statisticsValue, T maximumResultType);
-
- static Status _setTableLogging(WiredTigerSessionCache* sessionCache,
- const std::string& uri,
- bool on);
-
- // Used to keep track of the table logging setting modifications during start up. The mutex must
- // be held prior to accessing any of the member variables in the struct.
- static Mutex _tableLoggingInfoMutex;
- static struct TableLoggingInfo {
- bool isInitializing = true;
- bool isFirstTable = true;
- bool changeTableLogging = false;
- bool hasPreviouslyIncompleteTableChecks = false;
- } _tableLoggingInfo;
};
class WiredTigerConfigParser {