diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/storage/biggie/SConscript | 3 | ||||
-rw-r--r-- | src/mongo/db/storage/biggie/biggie_init.cpp | 26 | ||||
-rw-r--r-- | src/mongo/db/storage/biggie/biggie_record_store.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/storage/biggie/biggie_record_store.h | 3 | ||||
-rw-r--r-- | src/mongo/db/storage/biggie/biggie_server_status.cpp | 68 | ||||
-rw-r--r-- | src/mongo/db/storage/biggie/biggie_server_status.h | 54 |
6 files changed, 155 insertions, 2 deletions
diff --git a/src/mongo/db/storage/biggie/SConscript b/src/mongo/db/storage/biggie/SConscript index 7326768141a..d15cba68888 100644 --- a/src/mongo/db/storage/biggie/SConscript +++ b/src/mongo/db/storage/biggie/SConscript @@ -24,6 +24,7 @@ env.Library( '$BUILD_DIR/mongo/db/storage/key_string', '$BUILD_DIR/mongo/db/storage/oplog_hack', '$BUILD_DIR/mongo/db/storage/write_unit_of_work', + '$BUILD_DIR/mongo/db/commands/server_status', ], ) @@ -31,6 +32,7 @@ env.Library( target='storage_biggie', source=[ 'biggie_init.cpp', + 'biggie_server_status.cpp', ], LIBDEPS=[ '$BUILD_DIR/mongo/db/storage/durable_catalog_impl', @@ -39,6 +41,7 @@ env.Library( ], LIBDEPS_PRIVATE=[ '$BUILD_DIR/mongo/db/storage/storage_engine_common', + '$BUILD_DIR/mongo/db/commands/server_status', ], ) diff --git a/src/mongo/db/storage/biggie/biggie_init.cpp b/src/mongo/db/storage/biggie/biggie_init.cpp index f54a76a863d..148ec547ed8 100644 --- a/src/mongo/db/storage/biggie/biggie_init.cpp +++ b/src/mongo/db/storage/biggie/biggie_init.cpp @@ -32,10 +32,16 @@ #include "mongo/base/init.h" #include "mongo/db/service_context.h" #include "mongo/db/storage/biggie/biggie_kv_engine.h" +#include "mongo/db/storage/biggie/biggie_record_store.h" +#include "mongo/db/storage/biggie/biggie_server_status.h" #include "mongo/db/storage/storage_engine_impl.h" #include "mongo/db/storage/storage_engine_init.h" #include "mongo/db/storage/storage_options.h" +#if __has_feature(address_sanitizer) +#include <sanitizer/lsan_interface.h> +#endif + namespace mongo { namespace biggie { @@ -44,14 +50,30 @@ class BiggieStorageEngineFactory : public StorageEngine::Factory { public: virtual std::unique_ptr<StorageEngine> create(const StorageGlobalParams& params, const StorageEngineLockFile* lockFile) const { + auto kv = std::make_unique<KVEngine>(); + // We must only add the server parameters to the global registry once during unit testing. + static int setupCountForUnitTests = 0; + if (setupCountForUnitTests == 0) { + ++setupCountForUnitTests; + + // Intentionally leaked. + MONGO_COMPILER_VARIABLE_UNUSED auto leakedSection = + new BiggieServerStatusSection(kv.get()); + + // This allows unit tests to run this code without encountering memory leaks +#if __has_feature(address_sanitizer) + __lsan_ignore_object(leakedSection); +#endif + } + StorageEngineOptions options; options.directoryPerDB = params.directoryperdb; options.forRepair = params.repair; - return std::make_unique<StorageEngineImpl>(std::make_unique<KVEngine>(), options); + return std::make_unique<StorageEngineImpl>(std::move(kv), options); } virtual StringData getCanonicalName() const { - return "biggie"; + return kBiggieEngineName; } virtual Status validateMetadata(const StorageEngineMetadata& metadata, diff --git a/src/mongo/db/storage/biggie/biggie_record_store.cpp b/src/mongo/db/storage/biggie/biggie_record_store.cpp index 266097121b6..845a3f094a2 100644 --- a/src/mongo/db/storage/biggie/biggie_record_store.cpp +++ b/src/mongo/db/storage/biggie/biggie_record_store.cpp @@ -71,6 +71,9 @@ RecordId extractRecordId(const std::string& keyStr) { } } // namespace + +const std::string kBiggieEngineName = "biggie"; + RecordStore::RecordStore(StringData ns, StringData ident, bool isCapped, diff --git a/src/mongo/db/storage/biggie/biggie_record_store.h b/src/mongo/db/storage/biggie/biggie_record_store.h index bb0f6abbd75..6e8526312f0 100644 --- a/src/mongo/db/storage/biggie/biggie_record_store.h +++ b/src/mongo/db/storage/biggie/biggie_record_store.h @@ -43,6 +43,9 @@ namespace mongo { namespace biggie { +// TODO SERVER-38987: Change the name to EphemeralForTest. +extern const std::string kBiggieEngineName; + /** * A RecordStore that stores all data in-memory. */ diff --git a/src/mongo/db/storage/biggie/biggie_server_status.cpp b/src/mongo/db/storage/biggie/biggie_server_status.cpp new file mode 100644 index 00000000000..4bef5903c57 --- /dev/null +++ b/src/mongo/db/storage/biggie/biggie_server_status.cpp @@ -0,0 +1,68 @@ +/** + * Copyright (C) 2020-present MongoDB, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the Server Side Public License, version 1, + * as published by MongoDB, Inc. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * Server Side Public License for more details. + * + * You should have received a copy of the Server Side Public License + * along with this program. If not, see + * <http://www.mongodb.com/licensing/server-side-public-license>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the Server Side Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kFTDC + +#include "mongo/platform/basic.h" + +#include "mongo/db/storage/biggie/biggie_server_status.h" + +#include "mongo/bson/bsonobjbuilder.h" +#include "mongo/db/concurrency/d_concurrency.h" +#include "mongo/db/storage/biggie/biggie_kv_engine.h" +#include "mongo/db/storage/biggie/biggie_record_store.h" +#include "mongo/logv2/log.h" + +namespace mongo { +namespace biggie { + +BiggieServerStatusSection::BiggieServerStatusSection(KVEngine* engine) + : ServerStatusSection(kBiggieEngineName), _engine(engine) {} + +bool BiggieServerStatusSection::includeByDefault() const { + return true; +} + +BSONObj BiggieServerStatusSection::generateSection(OperationContext* opCtx, + const BSONElement& configElement) const { + Lock::GlobalLock lk( + opCtx, LockMode::MODE_IS, Date_t::now(), Lock::InterruptBehavior::kLeaveUnlocked); + if (!lk.isLocked()) { + LOGV2_DEBUG(4919800, 2, "Failed to retrieve biggie statistics"); + return BSONObj(); + } + + BSONObjBuilder bob; + bob.append("statisitcs", "TODO SERVER-49055"); + + return bob.obj(); +} + +} // namespace biggie +} // namespace mongo diff --git a/src/mongo/db/storage/biggie/biggie_server_status.h b/src/mongo/db/storage/biggie/biggie_server_status.h new file mode 100644 index 00000000000..4e1264af4ab --- /dev/null +++ b/src/mongo/db/storage/biggie/biggie_server_status.h @@ -0,0 +1,54 @@ +/** + * Copyright (C) 2020-present MongoDB, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the Server Side Public License, version 1, + * as published by MongoDB, Inc. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * Server Side Public License for more details. + * + * You should have received a copy of the Server Side Public License + * along with this program. If not, see + * <http://www.mongodb.com/licensing/server-side-public-license>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the Server Side Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#pragma once + +#include "mongo/db/commands/server_status.h" + +namespace mongo { +namespace biggie { + +class KVEngine; + +/** + * Adds "biggie" to the results of db.serverStatus(). + */ +class BiggieServerStatusSection : public ServerStatusSection { +public: + BiggieServerStatusSection(KVEngine* engine); + bool includeByDefault() const override; + BSONObj generateSection(OperationContext* opCtx, + const BSONElement& configElement) const override; + +private: + KVEngine* _engine; +}; + +} // namespace biggie +} // namespace mongo |