├── .gitignore
├── .clang-format
├── resmoke.sh
├── .arcconfig
├── resmokelist
├── src
├── KNOWN_ISSUES.md
├── rocks_record_store_mock.cpp
├── rocks_options_init.cpp
├── rocks_prepare_conflict.cpp
├── rocks_server_status.h
├── rocks_counter_manager.h
├── rocks_global_options.h
├── totdb
│ ├── totransaction.h
│ ├── totransaction_impl.h
│ ├── totransaction_prepare_iterator.h
│ ├── totransaction_db.h
│ └── totransaction_db_impl.h
├── rocks_global_options.cpp
├── mongo_rate_limiter_checker.h
├── rocks_util.h
├── rocks_begin_transaction_block.h
├── rocks_util.cpp
├── rocks_durability_manager.cpp
├── rocks_index_test.cpp
├── rocks_parameters.idl
├── rocks_begin_transaction_block.cpp
├── rocks_snapshot_manager.h
├── rocks_durability_manager.h
├── rocks_counter_manager.cpp
├── rocks_snapshot_manager.cpp
├── rocks_oplog_manager.h
├── rocks_compaction_scheduler.h
├── rocks_record_store_test.cpp
├── rocks_prepare_conflict.h
├── rocks_index.h
├── rocks_init.cpp
├── rocks_global_options.idl
├── mongo_rate_limiter_checker.cpp
├── rocks_record_store_mongod.cpp
├── rocks_parameters.cpp
└── rocks_oplog_manager.cpp
├── README.md
├── BUILD.md
├── CONTRIBUTING.md
└── SConscript
/.gitignore:
--------------------------------------------------------------------------------
1 | *.pyc
2 | *.sw*
3 |
--------------------------------------------------------------------------------
/.clang-format:
--------------------------------------------------------------------------------
1 | BasedOnStyle: Google
2 | AccessModifierOffset: -4
3 | ColumnLimit: 100
4 | IndentWidth: 4
5 | BreakBeforeBraces: Attach
6 | NamespaceIndentation: All
7 |
--------------------------------------------------------------------------------
/resmoke.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ulimit -n 100000
4 |
5 | for testcase in `cat resmokelist`
6 | do
7 | echo "run suite: " $testcase
8 | python buildscripts/resmoke.py --storageEngine rocksdb --suite=$testcase --dbpathPrefix=/root/mongo/ci -j1 1>$testcase.log 2>&1
9 | done
10 |
--------------------------------------------------------------------------------
/.arcconfig:
--------------------------------------------------------------------------------
1 | {
2 | "project_id" : "mongo-rocks",
3 | "conduit_uri" : "https://reviews.facebook.net/",
4 | "load" : [],
5 | "base" : "git:HEAD^, hg:.^",
6 | "git.default-relative-commit" : "HEAD^",
7 | "git:arc.feature.start.default" : "origin/master",
8 | "arc.feature.start.default" : "master",
9 | "history.immutable" : false
10 | }
11 |
--------------------------------------------------------------------------------
/resmokelist:
--------------------------------------------------------------------------------
1 | write_concern_majority_passthrough
2 | change_streams_whole_cluster_mongos_passthrough
3 | change_streams_whole_db_mongos_passthrough
4 | sharding_auth_12
5 | core_minimum_batch_size
6 | causally_consistent_jscore_txns_passthrough
7 | concurrency_simultaneous
8 | change_streams_secondary_reads
9 | replica_sets_initsync_jscore_passthrough
10 | sharding_10
11 | sharding_14
12 | core_op_query
13 | session_jscore_passthrough
14 | secondary_reads_passthrough
15 |
--------------------------------------------------------------------------------
/src/KNOWN_ISSUES.md:
--------------------------------------------------------------------------------
1 | MongoRocks r4.2.5
2 | 1) RocksDB layer bottommost compaction may be triggered frequently with no progress when enableMajorityReadConcern=true, TODO: add a issue somewhere
3 | 2) jstests/core/txns/commit_prepared_transaction_errors.js wont pass now because mongo-wt introduced the timestamped-safe unique index, which does dupkey check in wt-layer. mongoRocks does this in mongoRocks layer, which hangs into PrepareConflict error, while mongo-wt throws WriteConflict
4 | 3) src/mongo/db/storage/sorted_data_interface_test_dupkeycheck.cpp:TEST(SortedDataInterface, DupKeyCheckWithDuplicates) wont pass, because mongoRocks currently do not have timestamped-safe unique index
5 |
6 | MongoRocks r4.0.3
7 | 1) RocksDB layer bottommost compaction may be triggered frequently with no progress when enableMajorityReadConcern=true, TODO: add a issue somewhere
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## RocksDB Storage Engine Module for MongoDB
2 |
3 | ### Stable Versions/Branches
4 | + v3.2
5 | + v3.4
6 | + v4.0.3
7 | + v4.2.5
8 |
9 | ### How to build
10 | See BUILD.md
11 |
12 | ### More information
13 | To use this module, it has to be linked from `mongo/src/mongo/db/modules`. The build system will automatically recognize it. In the `mongo` repository directory do the following:
14 |
15 | mkdir -p src/mongo/db/modules/
16 | ln -sf ~/mongo-rocks src/mongo/db/modules/rocks
17 |
18 | To build you will need to first install the RocksDB library, see `INSTALL.md`
19 | at https://github.com/facebook/rocksdb for more information. If you install
20 | in non-standard locations, you may need to set `CPPPATH` and `LIBPATH`
21 | environment variables:
22 |
23 | CPPPATH=/myrocksdb/include LIBPATH=/myrocksdb/lib scons
24 |
25 | ### Reach out
26 | If you have any issues with MongoRocks, leave an issue on github's issue board.
27 |
--------------------------------------------------------------------------------
/BUILD.md:
--------------------------------------------------------------------------------
1 | Execute this series of commands to compile MongoDB with RocksDB storage engine:
2 | ```
3 | install compression libraries (zlib, bzip2, snappy):
4 | sudo apt-get install zlib1g-dev; sudo apt-get install libbz2-dev; sudo apt-get install libsnappy-dev
5 | # get rocksdb
6 | git clone https://github.com/facebook/rocksdb.git
7 | git checkout main
8 | # compile rocksdb
9 | cd rocksdb; USE_RTTI=1 CFLAGS=-fPIC make static_lib; sudo INSTALL_PATH=/usr make install; cd ..
10 | # get mongo
11 | git clone https://github.com/mongodb/mongo.git
12 | git checkout tags/r4.2.5 -b branch_tags_4.2.5
13 | # get mongorocks
14 | git clone https://github.com/mongodb-partners/mongo-rocks
15 | git checkout master
16 | # add rocksdb module to mongo
17 | mkdir -p mongo/src/mongo/db/modules/
18 | ln -sf ~/mongo-rocks mongo/src/mongo/db/modules/rocks
19 | # compile mongo
20 | cd mongo; scons
21 | ```
22 | Start `mongod` using the `--storageEngine=rocksdb` option.
23 |
24 |
25 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | When contributing to this repository, please first discuss the change you wish to make via issue,
4 | email, or any other method with the owners of this repository before making a change.
5 |
6 | Please note we have a code of conduct, please follow it in all your interactions with the project.
7 |
8 | ## Pull Request Process
9 |
10 | 1. Ensure any install or build dependencies are removed before the end of the layer when doing a build.
11 | 2. Make sure you add unittests/cpptests for what you write, although not forced. Unfortunaly, it's impossible to add more resmoke tests/js tests because they are in mongodb's code base.
12 | 3. It is encouraged to make pull request to the **master** branch, which tracks the latest develop activities. Pull requests to other branchs are only limited to bug fixes.
13 |
14 | ## Code of Conduct
15 |
16 | ### Code Standards
17 |
18 | MongoRocks follows mongodb's code-style. Which is similiar with google-c++-code-style. It's highly suggested you **clang-format** your code before making the pull request. It's not forced but advised.
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/rocks_record_store_mock.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 MongoDB Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License, version 3,
6 | * as published by the Free Software Foundation.
7 | *
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Affero General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Affero General Public License
15 | * along with this program. If not, see .
16 | *
17 | * As a special exception, the copyright holders give permission to link the
18 | * code of portions of this program with the OpenSSL library under certain
19 | * conditions as described in each individual source file and distribute
20 | * linked combinations including the program with the OpenSSL library. You
21 | * must comply with the GNU Affero General Public License in all respects for
22 | * all of the code used other than as permitted herein. If you modify file(s)
23 | * with this exception, you may extend this exception to your version of the
24 | * file(s), but you are not obligated to do so. If you do not wish to do so,
25 | * delete this exception statement from your version. If you delete this
26 | * exception statement from all source files in the program, then also delete
27 | * it in the license file.
28 | */
29 |
30 | #include "mongo/platform/basic.h"
31 |
32 | #include "mongo/base/init.h"
33 | #include "mongo/db/namespace_string.h"
34 | #include "mongo/db/operation_context_noop.h"
35 | #include "mongo/db/service_context.h"
36 | #include "mongo/stdx/memory.h"
37 |
38 | #include "rocks_engine.h"
39 |
40 | namespace mongo {
41 |
42 | // static
43 | bool RocksEngine::initRsOplogBackgroundThread(StringData ns) {
44 | return NamespaceString::oplog(ns);
45 | }
46 |
47 | } // namespace mongo
48 |
--------------------------------------------------------------------------------
/src/rocks_options_init.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 MongoDB Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License, version 3,
6 | * as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | *
16 | * As a special exception, the copyright holders give permission to link the
17 | * code of portions of this program with the OpenSSL library under certain
18 | * conditions as described in each individual source file and distribute
19 | * linked combinations including the program with the OpenSSL library. You
20 | * must comply with the GNU Affero General Public License in all respects for
21 | * all of the code used other than as permitted herein. If you modify file(s)
22 | * with this exception, you may extend this exception to your version of the
23 | * file(s), but you are not obligated to do so. If you do not wish to do so,
24 | * delete this exception statement from your version. If you delete this
25 | * exception statement from all source files in the program, then also delete
26 | * it in the license file.
27 | */
28 |
29 | #include
30 |
31 | #include "mongo/util/exit_code.h"
32 | #include "mongo/util/options_parser/startup_option_init.h"
33 | #include "mongo/util/options_parser/startup_options.h"
34 |
35 | #include "rocks_global_options.h"
36 |
37 | namespace moe = mongo::optionenvironment;
38 |
39 | namespace mongo {
40 |
41 | MONGO_STARTUP_OPTIONS_STORE(RocksOptions)(InitializerContext* context) {
42 | Status ret = rocksGlobalOptions.store(moe::startupOptionsParsed);
43 | if (!ret.isOK()) {
44 | std::cerr << ret.toString() << std::endl;
45 | std::cerr << "try '" << context->args()[0] << " --help' for more information"
46 | << std::endl;
47 | ::_exit(EXIT_BADOPTIONS);
48 | }
49 | return Status::OK();
50 | }
51 | } // namespace mongo
52 |
--------------------------------------------------------------------------------
/src/rocks_prepare_conflict.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2018-present MongoDB, Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the Server Side Public License, version 1,
6 | * as published by MongoDB, Inc.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * Server Side Public License for more details.
12 | *
13 | * You should have received a copy of the Server Side Public License
14 | * along with this program. If not, see
15 | * .
16 | *
17 | * As a special exception, the copyright holders give permission to link the
18 | * code of portions of this program with the OpenSSL library under certain
19 | * conditions as described in each individual source file and distribute
20 | * linked combinations including the program with the OpenSSL library. You
21 | * must comply with the Server Side Public License in all respects for
22 | * all of the code used other than as permitted herein. If you modify file(s)
23 | * with this exception, you may extend this exception to your version of the
24 | * file(s), but you are not obligated to do so. If you do not wish to do so,
25 | * delete this exception statement from your version. If you delete this
26 | * exception statement from all source files in the program, then also delete
27 | * it in the license file.
28 | */
29 |
30 | #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kStorage
31 |
32 | #include "mongo/platform/basic.h"
33 | #include "rocks_prepare_conflict.h"
34 | #include "mongo/util/fail_point_service.h"
35 | #include "mongo/util/log.h"
36 |
37 | namespace mongo {
38 |
39 | // When set, simulates WT_PREPARE_CONFLICT returned from WiredTiger API calls.
40 | MONGO_FAIL_POINT_DEFINE(RocksPrepareConflictForReads);
41 |
42 | MONGO_FAIL_POINT_DEFINE(RocksSkipPrepareConflictRetries);
43 |
44 | MONGO_FAIL_POINT_DEFINE(RocksPrintPrepareConflictLog);
45 |
46 | void rocksPrepareConflictLog(int attempts) {
47 | LOG(1) << "Caught ROCKS_PREPARE_CONFLICT, attempt " << attempts
48 | << ". Waiting for unit of work to commit or abort.";
49 | }
50 |
51 | void rocksPrepareConflictFailPointLog() {
52 | log() << "RocksPrintPrepareConflictLog fail point enabled.";
53 | }
54 |
55 | } // namespace mongo
56 |
--------------------------------------------------------------------------------
/src/rocks_server_status.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 MongoDB Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License, version 3,
6 | * as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | *
16 | * As a special exception, the copyright holders give permission to link the
17 | * code of portions of this program with the OpenSSL library under certain
18 | * conditions as described in each individual source file and distribute
19 | * linked combinations including the program with the OpenSSL library. You
20 | * must comply with the GNU Affero General Public License in all respects for
21 | * all of the code used other than as permitted herein. If you modify file(s)
22 | * with this exception, you may extend this exception to your version of the
23 | * file(s), but you are not obligated to do so. If you do not wish to do so,
24 | * delete this exception statement from your version. If you delete this
25 | * exception statement from all source files in the program, then also delete
26 | * it in the license file.
27 | */
28 |
29 | #pragma once
30 |
31 | #include "mongo/db/commands/server_status.h"
32 |
33 | namespace mongo {
34 |
35 | class RocksEngine;
36 |
37 | /**
38 | * Adds "rocksdb" to the results of db.serverStatus().
39 | */
40 | class RocksServerStatusSection : public ServerStatusSection {
41 | public:
42 | RocksServerStatusSection(RocksEngine* engine);
43 | bool includeByDefault() const override;
44 | BSONObj generateSection(OperationContext* opCtx,
45 | const BSONElement& configElement) const override;
46 |
47 | protected:
48 | virtual void generatePropertiesSection(BSONObjBuilder* bob) const;
49 | virtual void generateThreadStatusSection(BSONObjBuilder* bob) const;
50 | virtual void generateCountersSection(BSONObjBuilder* bob) const;
51 | virtual void generateTxnStatsSection(BSONObjBuilder* bob) const;
52 | virtual void generateOplogDelStatsSection(BSONObjBuilder* bob) const;
53 | virtual void generateCompactSchedulerSection(BSONObjBuilder* bob) const;
54 | virtual void generateDefaultCFEntriesNumSection(BSONObjBuilder* bob) const;
55 | private:
56 | RocksEngine* _engine;
57 | };
58 |
59 | } // namespace mongo
60 |
--------------------------------------------------------------------------------
/src/rocks_counter_manager.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 MongoDB Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License, version 3,
6 | * as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | *
16 | * As a special exception, the copyright holders give permission to link the
17 | * code of portions of this program with the OpenSSL library under certain
18 | * conditions as described in each individual source file and distribute
19 | * linked combinations including the program with the OpenSSL library. You
20 | * must comply with the GNU Affero General Public License in all respects for
21 | * all of the code used other than as permitted herein. If you modify file(s)
22 | * with this exception, you may extend this exception to your version of the
23 | * file(s), but you are not obligated to do so. If you do not wish to do so,
24 | * delete this exception statement from your version. If you delete this
25 | * exception statement from all source files in the program, then also delete
26 | * it in the license file.
27 | */
28 |
29 | #pragma once
30 |
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 |
38 | #include
39 | #include
40 | #include "mongo/db/modules/rocks/src/totdb/totransaction.h"
41 | #include "mongo/db/modules/rocks/src/totdb/totransaction_db.h"
42 |
43 | #include "mongo/base/string_data.h"
44 | #include "mongo/platform/mutex.h"
45 |
46 | namespace mongo {
47 |
48 | class RocksCounterManager {
49 | public:
50 | RocksCounterManager(rocksdb::TOTransactionDB* db, rocksdb::ColumnFamilyHandle* cf, bool crashSafe)
51 | : _db(db), _cf(cf), _crashSafe(crashSafe), _syncCounter(0) {}
52 |
53 | long long loadCounter(const std::string& counterKey);
54 |
55 | void updateCounter(const std::string& counterKey, long long count);
56 |
57 | void sync();
58 |
59 | bool crashSafe() const { return _crashSafe; }
60 |
61 | private:
62 | static rocksdb::Slice _encodeCounter(long long counter, int64_t* storage);
63 |
64 | rocksdb::TOTransactionDB* _db; // not owned
65 |
66 | rocksdb::ColumnFamilyHandle* _cf; // not owned
67 |
68 | const bool _crashSafe;
69 |
70 | Mutex _lock = MONGO_MAKE_LATCH("RocksCounterManager::_lock");
71 |
72 | // protected by _lock
73 | std::unordered_map _counters;
74 | // protected by _lock
75 | int _syncCounter;
76 |
77 | static const int kSyncEvery = 10000;
78 | };
79 | } // namespace mongo
80 |
--------------------------------------------------------------------------------
/src/rocks_global_options.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 MongoDB Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License, version 3,
6 | * as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | *
16 | * As a special exception, the copyright holders give permission to link the
17 | * code of portions of this program with the OpenSSL library under certain
18 | * conditions as described in each individual source file and distribute
19 | * linked combinations including the program with the OpenSSL library. You
20 | * must comply with the GNU Affero General Public License in all respects for
21 | * all of the code used other than as permitted herein. If you modify file(s)
22 | * with this exception, you may extend this exception to your version of the
23 | * file(s), but you are not obligated to do so. If you do not wish to do so,
24 | * delete this exception statement from your version. If you delete this
25 | * exception statement from all source files in the program, then also delete
26 | * it in the license file.
27 | */
28 |
29 | #pragma once
30 |
31 | #include "mongo/util/options_parser/startup_option_init.h"
32 | #include "mongo/util/options_parser/startup_options.h"
33 |
34 | namespace mongo {
35 |
36 | class RocksGlobalOptions {
37 | public:
38 | RocksGlobalOptions()
39 | : cacheSizeGB(0),
40 | maxWriteMBPerSec(1024),
41 | compression("snappy"),
42 | crashSafeCounters(false),
43 | counters(true),
44 | singleDeleteIndex(false),
45 | logLevel("info"),
46 | maxConflictCheckSizeMB(200) {}
47 |
48 | Status store(const optionenvironment::Environment& params);
49 | static Status validateRocksdbLogLevel(const std::string& value);
50 | static Status validateRocksdbCompressor(const std::string& value);
51 | size_t cacheSizeGB;
52 | int maxWriteMBPerSec;
53 |
54 | std::string compression;
55 | std::string configString;
56 |
57 | bool crashSafeCounters;
58 | bool counters;
59 | bool singleDeleteIndex;
60 |
61 | std::string logLevel;
62 | int maxConflictCheckSizeMB;
63 | int maxBackgroundJobs;
64 | long maxTotalWalSize;
65 | long dbWriteBufferSize;
66 | long writeBufferSize;
67 | long delayedWriteRate;
68 | int numLevels;
69 | int maxWriteBufferNumber;
70 | int level0FileNumCompactionTrigger;
71 | int level0SlowdownWritesTrigger;
72 | int level0StopWritesTrigger;
73 | long maxBytesForLevelBase;
74 | int softPendingCompactionMBLimit;
75 | int hardPendingCompactionMBLimit;
76 | };
77 |
78 | extern RocksGlobalOptions rocksGlobalOptions;
79 | } // namespace mongo
80 |
--------------------------------------------------------------------------------
/src/totdb/totransaction.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #ifndef ROCKSDB_LITE
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | #include "rocksdb/comparator.h"
11 | #include "rocksdb/db.h"
12 | #include "rocksdb/status.h"
13 |
14 | namespace rocksdb {
15 |
16 | class Iterator;
17 | class TransactionDB;
18 | class WriteBatchWithIndex;
19 |
20 | using TransactionName = std::string;
21 |
22 | using TransactionID = uint64_t;
23 |
24 | //TimeStamp in rocksdb
25 | using RocksTimeStamp = uint64_t;
26 |
27 | //TimeStamp Ordering Transaction
28 | class TOTransaction {
29 | public:
30 | virtual ~TOTransaction() {}
31 |
32 | // set prepare timestamp for transaction, if the application set the prepare
33 | // timestamp twice, an error will be returned
34 | virtual Status SetPrepareTimeStamp(const RocksTimeStamp& timestamp) = 0;
35 |
36 | virtual Status SetCommitTimeStamp(const RocksTimeStamp& timestamp) = 0;
37 |
38 | virtual Status SetDurableTimeStamp(const RocksTimeStamp& timestamp) = 0;
39 |
40 | // set read timestamp for transaction, if the application set the commit timestamp twice, an error will be returned
41 | virtual Status SetReadTimeStamp(const RocksTimeStamp& timestamp) = 0;
42 |
43 | virtual Status GetReadTimeStamp(RocksTimeStamp* timestamp) const = 0;
44 |
45 | virtual Status Prepare() = 0;
46 |
47 | virtual Status Commit(std::function* hook = nullptr) = 0;
48 |
49 | virtual Status Rollback() = 0;
50 |
51 | virtual Status Get(ReadOptions& options,
52 | ColumnFamilyHandle* column_family, const Slice& key,
53 | std::string* value) = 0;
54 |
55 | virtual Status Get(ReadOptions& options, const Slice& key,
56 | std::string* value) = 0;
57 |
58 | virtual Iterator* GetIterator(ReadOptions& read_options) = 0;
59 |
60 | virtual Iterator* GetIterator(ReadOptions& read_options,
61 | ColumnFamilyHandle* column_family) = 0;
62 |
63 | virtual Status Put(ColumnFamilyHandle* column_family, const Slice& key,
64 | const Slice& value) = 0;
65 | virtual Status Put(const Slice& key, const Slice& value) = 0;
66 |
67 | virtual Status Delete(ColumnFamilyHandle* column_family, const Slice& key) = 0;
68 | virtual Status Delete(const Slice& key) = 0;
69 |
70 | virtual Status GetForUpdate(ColumnFamilyHandle* column_family, const Slice& key) = 0;
71 | virtual Status GetForUpdate(const Slice& key) = 0;
72 |
73 | virtual WriteBatchWithIndex* GetWriteBatch() = 0;
74 |
75 | virtual Status SetName(const TransactionName& name) = 0;
76 |
77 | virtual TransactionName GetName() const { return name_; }
78 |
79 | virtual TransactionID GetID() const { return 0; }
80 |
81 | enum TOTransactionState {
82 | kStarted = 0,
83 | kPrepared = 1,
84 | kCommitted = 2,
85 | kRollback = 3,
86 | };
87 |
88 | virtual TOTransactionState GetState() const = 0;
89 |
90 | static void enableTimestamp(const std::string& prefix);
91 | static bool isEnableTimestamp(const Slice& key);
92 | static std::set timestampPrefixes;
93 | static std::mutex prefixes_mutex;
94 |
95 | protected:
96 | explicit TOTransaction(const DB* /*db*/) {}
97 | TOTransaction() {}
98 |
99 | TransactionName name_;
100 | };
101 |
102 | } // namespace rocksdb
103 |
104 | #endif
105 |
106 |
--------------------------------------------------------------------------------
/src/rocks_global_options.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 MongoDB Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License, version 3,
6 | * as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | *
16 | * As a special exception, the copyright holders give permission to link the
17 | * code of portions of this program with the OpenSSL library under certain
18 | * conditions as described in each individual source file and distribute
19 | * linked combinations including the program with the OpenSSL library. You
20 | * must comply with the GNU Affero General Public License in all respects for
21 | * all of the code used other than as permitted herein. If you modify file(s)
22 | * with this exception, you may extend this exception to your version of the
23 | * file(s), but you are not obligated to do so. If you do not wish to do so,
24 | * delete this exception statement from your version. If you delete this
25 | * exception statement from all source files in the program, then also delete
26 | * it in the license file.
27 | */
28 |
29 | #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kStorage
30 |
31 | #include "mongo/platform/basic.h"
32 |
33 | #include "mongo/base/status.h"
34 | #include "mongo/util/log.h"
35 | #include "mongo/util/options_parser/constraints.h"
36 |
37 | #include "rocks_global_options.h"
38 |
39 | namespace moe = mongo::optionenvironment;
40 |
41 | namespace mongo {
42 |
43 | RocksGlobalOptions rocksGlobalOptions;
44 |
45 | Status RocksGlobalOptions::store(const optionenvironment::Environment& params) {
46 | return Status::OK();
47 | }
48 |
49 | Status RocksGlobalOptions::validateRocksdbLogLevel(const std::string& value) {
50 | constexpr auto kDebug = "debug"_sd;
51 | constexpr auto kInfo = "info"_sd;
52 | constexpr auto kWarn = "warn"_sd;
53 | constexpr auto kError = "error"_sd;
54 |
55 | if (!kDebug.equalCaseInsensitive(value) && !kInfo.equalCaseInsensitive(value) &&
56 | !kWarn.equalCaseInsensitive(value) && !kError.equalCaseInsensitive(value)) {
57 | return {ErrorCodes::BadValue,
58 | "Compression option must be one of: 'debug', 'info', 'warn', or 'error'"};
59 | }
60 |
61 | return Status::OK();
62 | }
63 |
64 | Status RocksGlobalOptions::validateRocksdbCompressor(const std::string& value) {
65 | constexpr auto kNone = "none"_sd;
66 | constexpr auto kSnappy = "snappy"_sd;
67 | constexpr auto kZlib = "zlib"_sd;
68 | constexpr auto kZstd = "zstd"_sd;
69 |
70 | if (!kNone.equalCaseInsensitive(value) && !kSnappy.equalCaseInsensitive(value) &&
71 | !kZlib.equalCaseInsensitive(value) && !kZstd.equalCaseInsensitive(value)) {
72 | return {ErrorCodes::BadValue,
73 | "Compression option must be one of: 'none', 'snappy', 'zlib', or 'zstd'"};
74 | }
75 |
76 | return Status::OK();
77 | }
78 | } // namespace mongo
79 |
--------------------------------------------------------------------------------
/src/mongo_rate_limiter_checker.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 MongoDB Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License, version 3,
6 | * as published by the Free Software Foundation.
7 | *
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Affero General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Affero General Public License
15 | * along with this program. If not, see .
16 | *
17 | * As a special exception, the copyright holders give permission to link the
18 | * code of portions of this program with the OpenSSL library under certain
19 | * conditions as described in each individual source file and distribute
20 | * linked combinations including the program with the OpenSSL library. You
21 | * must comply with the GNU Affero General Public License in all respects for
22 | * all of the code used other than as permitted herein. If you modify file(s)
23 | * with this exception, you may extend this exception to your version of the
24 | * file(s), but you are not obligated to do so. If you do not wish to do so,
25 | * delete this exception statement from your version. If you delete this
26 | * exception statement from all source files in the program, then also delete
27 | * it in the license file.
28 | */
29 |
30 | #pragma once
31 |
32 | #ifdef __linux__
33 | #include
34 | #include "mongo/bson/bsonobjbuilder.h"
35 |
36 | namespace mongo {
37 |
38 | const uint64_t kMinMongoRateLimitRequestTokens = 100;
39 | const uint64_t kInitMongoRateLimitRequestTokens = 1000000;
40 |
41 | class MongoRateLimiter {
42 | public:
43 | MongoRateLimiter(rocksdb::RateLimiter* rateLimiter)
44 | : _rateLimiter(rateLimiter), _requestTokens(0) {}
45 | virtual ~MongoRateLimiter() {}
46 |
47 | virtual void resetRequestTokens() {
48 | _requestTokens.store(0, std::memory_order_relaxed);
49 | }
50 | virtual int64_t getRequestTokens() {
51 | return _requestTokens.load(std::memory_order_relaxed);
52 | }
53 | virtual void resetTokensPerSecond(int64_t tokens_per_second) {
54 | _rateLimiter->SetBytesPerSecond(tokens_per_second);
55 | }
56 | virtual int64_t getTokensPerSecond() {
57 | return _rateLimiter->GetBytesPerSecond();
58 | }
59 | virtual void request(const int64_t bytes) {
60 | auto requestTokens = _requestTokens.load(std::memory_order_relaxed);
61 | _requestTokens.store(requestTokens + bytes, std::memory_order_relaxed);
62 | _rateLimiter->Request(bytes, rocksdb::Env::IOPriority::IO_HIGH);
63 | }
64 |
65 | private:
66 | std::unique_ptr _rateLimiter;
67 | std::atomic _requestTokens;
68 | };
69 |
70 | struct DiskStats {
71 | DiskStats() : micros(0), reads(0), writes(0), read_sectors(0), write_sectors(0) {}
72 | DiskStats(const BSONObj& diskStatsObj) {
73 | micros = curTimeMicros64();
74 | reads = static_cast(diskStatsObj.getField("reads").safeNumberLong());
75 | writes = static_cast(diskStatsObj.getField("writes").safeNumberLong());
76 | read_sectors =
77 | static_cast(diskStatsObj.getField("read_sectors").safeNumberLong());
78 | write_sectors =
79 | static_cast(diskStatsObj.getField("write_sectors").safeNumberLong());
80 | }
81 | uint64_t micros;
82 | uint64_t reads;
83 | uint64_t writes;
84 | uint64_t read_sectors;
85 | uint64_t write_sectors;
86 | };
87 |
88 | MongoRateLimiter* getMongoRateLimiter();
89 |
90 | void startMongoRateLimiterChecker();
91 | }
92 | #endif
93 |
--------------------------------------------------------------------------------
/src/rocks_util.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 MongoDB Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License, version 3,
6 | * as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | *
16 | * As a special exception, the copyright holders give permission to link the
17 | * code of portions of this program with the OpenSSL library under certain
18 | * conditions as described in each individual source file and distribute
19 | * linked combinations including the program with the OpenSSL library. You
20 | * must comply with the GNU Affero General Public License in all respects for
21 | * all of the code used other than as permitted herein. If you modify file(s)
22 | * with this exception, you may extend this exception to your version of the
23 | * file(s), but you are not obligated to do so. If you do not wish to do so,
24 | * delete this exception statement from your version. If you delete this
25 | * exception statement from all source files in the program, then also delete
26 | * it in the license file.
27 | */
28 |
29 | #pragma once
30 |
31 | #include
32 | #include
33 | #include
34 | #include "mongo/util/assert_util.h"
35 |
36 | namespace mongo {
37 | class MongoRocksLogger : public rocksdb::Logger {
38 | public:
39 | MongoRocksLogger() : rocksdb::Logger(rocksdb::InfoLogLevel::INFO_LEVEL) {}
40 |
41 | // Write an entry to the log file with the specified format.
42 | virtual void Logv(const char* format, va_list ap) override;
43 | using rocksdb::Logger::Logv;
44 | };
45 |
46 | inline std::string rocksGetNextPrefix(const rocksdb::Slice& prefix) {
47 | // next prefix lexicographically, assume same length
48 | std::string nextPrefix(prefix.data(), prefix.size());
49 | for (int i = static_cast(nextPrefix.size()) - 1; i >= 0; --i) {
50 | nextPrefix[i]++;
51 | // if it's == 0, that means we've overflowed, so need to keep adding
52 | if (nextPrefix[i] != 0) {
53 | break;
54 | }
55 | }
56 | return nextPrefix;
57 | }
58 |
59 | std::string encodePrefix(uint32_t prefix);
60 | bool extractPrefix(const rocksdb::Slice& slice, uint32_t* prefix);
61 | int get_internal_delete_skipped_count();
62 |
63 | Status rocksToMongoStatus_slow(const rocksdb::Status& status, const char* prefix);
64 |
65 | /**
66 | * converts rocksdb status to mongodb status
67 | */
68 | inline Status rocksToMongoStatus(const rocksdb::Status& status, const char* prefix = NULL) {
69 | if (MONGO_likely(status.ok())) {
70 | return Status::OK();
71 | }
72 | return rocksToMongoStatus_slow(status, prefix);
73 | }
74 |
75 | #define invariantRocksOK(expression) \
76 | do { \
77 | auto _invariantRocksOK_status = expression; \
78 | if (MONGO_unlikely(!_invariantRocksOK_status.ok())) { \
79 | invariantOKFailed(#expression, rocksToMongoStatus(_invariantRocksOK_status), __FILE__, \
80 | __LINE__); \
81 | } \
82 | } while (false)
83 |
84 | #define checkRocks
85 |
86 | } // namespace mongo
87 |
--------------------------------------------------------------------------------
/src/rocks_begin_transaction_block.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2018 MongoDB Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License, version 3,
6 | * as published by the Free Software Foundation.
7 | *
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Affero General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Affero General Public License
15 | * along with this program. If not, see .
16 | *
17 | * As a special exception, the copyright holders give permission to link the
18 | * code of portions of this program with the OpenSSL library under certain
19 | * conditions as described in each individual source file and distribute
20 | * linked combinations including the program with the OpenSSL library. You
21 | * must comply with the GNU Affero General Public License in all respects for
22 | * all of the code used other than as permitted herein. If you modify file(s)
23 | * with this exception, you may extend this exception to your version of the
24 | * file(s), but you are not obligated to do so. If you do not wish to do so,
25 | * delete this exception statement from your version. If you delete this
26 | * exception statement from all source files in the program, then also delete
27 | * it in the license file.
28 | */
29 |
30 | #pragma once
31 |
32 | #include "mongo/db/modules/rocks/src/totdb/totransaction.h"
33 | #include "mongo/db/modules/rocks/src/totdb/totransaction_db.h"
34 | #include "mongo/base/status.h"
35 | #include "mongo/bson/timestamp.h"
36 | #include "mongo/db/storage/recovery_unit.h"
37 |
38 | namespace mongo {
39 |
40 | /**
41 | * When constructed, this object begins a Rocks transaction on the provided session. The
42 | * transaction will be rolled back if done() is not called before the object is destructed.
43 | */
44 | class RocksBeginTxnBlock {
45 | public:
46 | // Whether or not to round up to the oldest timestamp when the read timestamp is behind it.
47 | enum class RoundUpReadTimestamp {
48 | kNoRound, // Do not round to the oldest timestamp. BadValue error may be returned.
49 | kRound // Round the read timestamp up to the oldest timestamp when it is behind.
50 | };
51 |
52 | // Dictates whether to round up prepare and commit timestamp of a prepared transaction.
53 | // 'kNoRound' - Does not round up prepare and commit timestamp of a prepared transaction.
54 | // 'kRound' - The prepare timestamp will be rounded up to the oldest timestamp if found to
55 | // be earlier; and the commit timestamp will be rounded up to the prepare timestamp if
56 | // found to be earlier.
57 | enum class RoundUpPreparedTimestamps { kNoRound, kRound };
58 |
59 | RocksBeginTxnBlock(
60 | rocksdb::TOTransactionDB* db, std::unique_ptr* txn,
61 | PrepareConflictBehavior prepareConflictBehavior,
62 | RoundUpPreparedTimestamps roundUpPreparedTimestamps,
63 | RoundUpReadTimestamp roundUpReadTimestamp = RoundUpReadTimestamp::kNoRound);
64 |
65 | ~RocksBeginTxnBlock();
66 |
67 | /**
68 | * End the begin transaction block. Must be called to ensure the opened transaction
69 | * is not be rolled back.
70 | */
71 | void done();
72 |
73 | /**
74 | * Sets the read timestamp on the opened transaction. Cannot be called after a call to
75 | * done().
76 | */
77 | Status setReadSnapshot(Timestamp);
78 |
79 | /* Get the read timestamp on the opened transaction */
80 | Timestamp getTimestamp() const;
81 |
82 | private:
83 | rocksdb::TOTransactionDB* _db; // not own
84 | rocksdb::TOTransaction* _transaction; // not own
85 | bool _rollback = false; // not own
86 | Timestamp _readTimestamp; // not own
87 | };
88 |
89 | } // namespace mongo
90 |
--------------------------------------------------------------------------------
/src/rocks_util.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 MongoDB Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License, version 3,
6 | * as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | *
16 | * As a special exception, the copyright holders give permission to link the
17 | * code of portions of this program with the OpenSSL library under certain
18 | * conditions as described in each individual source file and distribute
19 | * linked combinations including the program with the OpenSSL library. You
20 | * must comply with the GNU Affero General Public License in all respects for
21 | * all of the code used other than as permitted herein. If you modify file(s)
22 | * with this exception, you may extend this exception to your version of the
23 | * file(s), but you are not obligated to do so. If you do not wish to do so,
24 | * delete this exception statement from your version. If you delete this
25 | * exception statement from all source files in the program, then also delete
26 | * it in the license file.
27 | */
28 | #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kStorage
29 |
30 | #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kStorage
31 |
32 | #include "rocks_util.h"
33 |
34 | #include
35 | #include
36 | #include
37 | #include
38 |
39 | // Temporary fix for https://github.com/facebook/rocksdb/pull/2336#issuecomment-303226208
40 | #define ROCKSDB_SUPPORT_THREAD_LOCAL
41 | #include
42 | #include
43 |
44 | #include "mongo/db/concurrency/write_conflict_exception.h"
45 | #include "mongo/platform/endian.h"
46 | #include "mongo/util/log.h"
47 |
48 | namespace mongo {
49 | std::string encodePrefix(uint32_t prefix) {
50 | uint32_t bigEndianPrefix = endian::nativeToBig(prefix);
51 | return std::string(reinterpret_cast(&bigEndianPrefix), sizeof(uint32_t));
52 | }
53 |
54 | // we encode prefixes in big endian because we want to quickly jump to the max prefix
55 | // (iter->SeekToLast())
56 | bool extractPrefix(const rocksdb::Slice& slice, uint32_t* prefix) {
57 | if (slice.size() < sizeof(uint32_t)) {
58 | return false;
59 | }
60 | *prefix = endian::bigToNative(*reinterpret_cast(slice.data()));
61 | return true;
62 | }
63 |
64 | int get_internal_delete_skipped_count() {
65 | #if ROCKSDB_MAJOR > 5 || (ROCKSDB_MAJOR == 5 && ROCKSDB_MINOR >= 6)
66 | return rocksdb::get_perf_context()->internal_delete_skipped_count;
67 | #else
68 | return rocksdb::perf_context.internal_delete_skipped_count;
69 | #endif
70 | }
71 |
72 | Status rocksToMongoStatus_slow(const rocksdb::Status& status, const char* prefix) {
73 | if (status.ok()) {
74 | return Status::OK();
75 | }
76 |
77 | if (status.IsBusy()) {
78 | throw WriteConflictException();
79 | }
80 |
81 | if (status.IsCorruption() || status.IsInvalidArgument()) {
82 | return Status(ErrorCodes::BadValue, status.ToString());
83 | }
84 |
85 | return Status(ErrorCodes::InternalError, status.ToString());
86 | }
87 |
88 | void MongoRocksLogger::Logv(const char* format, va_list ap) {
89 | char buffer[8192];
90 | int len = snprintf(buffer, sizeof(buffer), "[RocksDB]:");
91 | if (0 > len) {
92 | mongo::log() << "MongoRocksLogger::Logv return NEGATIVE value.";
93 | return;
94 | }
95 | vsnprintf(buffer + len, sizeof(buffer) - len, format, ap);
96 | log() << buffer;
97 | }
98 |
99 | } // namespace mongo
100 |
--------------------------------------------------------------------------------
/src/rocks_durability_manager.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 MongoDB Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License, version 3,
6 | * as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | *
16 | * As a special exception, the copyright holders give permission to link the
17 | * code of portions of this program with the OpenSSL library under certain
18 | * conditions as described in each individual source file and distribute
19 | * linked combinations including the program with the OpenSSL library. You
20 | * must comply with the GNU Affero General Public License in all respects for
21 | * all of the code used other than as permitted herein. If you modify file(s)
22 | * with this exception, you may extend this exception to your version of the
23 | * file(s), but you are not obligated to do so. If you do not wish to do so,
24 | * delete this exception statement from your version. If you delete this
25 | * exception statement from all source files in the program, then also delete
26 | * it in the license file.
27 | */
28 |
29 | #include "mongo/db/storage/journal_listener.h"
30 |
31 | #include
32 |
33 | #include "rocks_durability_manager.h"
34 | #include "rocks_util.h"
35 |
36 | namespace mongo {
37 | RocksDurabilityManager::RocksDurabilityManager(rocksdb::DB* db, bool durable,
38 | rocksdb::ColumnFamilyHandle* defaultCf,
39 | rocksdb::ColumnFamilyHandle* oplogCf)
40 | : _db(db),
41 | _durable(durable),
42 | _defaultCf(defaultCf),
43 | _oplogCf(oplogCf),
44 | _journalListener(&NoOpJournalListener::instance) {}
45 |
46 | void RocksDurabilityManager::setJournalListener(JournalListener* jl) {
47 | stdx::unique_lock lk(_journalListenerMutex);
48 | _journalListener = jl;
49 | }
50 |
51 | // TODO(cuixin): rtt should modify waitUntilDurable
52 | void RocksDurabilityManager::waitUntilDurable(bool forceFlush) {
53 | uint32_t start = _lastSyncTime.load();
54 | // Do the remainder in a critical section that ensures only a single thread at a time
55 | // will attempt to synchronize.
56 | stdx::unique_lock lk(_lastSyncMutex);
57 | uint32_t current = _lastSyncTime.loadRelaxed(); // synchronized with writes through mutex
58 | if (current != start) {
59 | // Someone else synced already since we read lastSyncTime, so we're done!
60 | return;
61 | }
62 | _lastSyncTime.store(current + 1);
63 |
64 | stdx::unique_lock jlk(_journalListenerMutex);
65 | JournalListener::Token token = _journalListener->getToken();
66 | if (!_durable || forceFlush) {
67 | invariantRocksOK(_db->Flush(rocksdb::FlushOptions(), {_defaultCf, _oplogCf}));
68 | } else {
69 | invariantRocksOK(_db->SyncWAL());
70 | }
71 | _journalListener->onDurable(token);
72 | }
73 |
74 | void RocksDurabilityManager::waitUntilPreparedUnitOfWorkCommitsOrAborts(
75 | OperationContext* opCtx, std::uint64_t lastCount) {
76 | invariant(opCtx);
77 | stdx::unique_lock lk(_prepareCommittedOrAbortedMutex);
78 | if (lastCount == _prepareCommitOrAbortCounter.loadRelaxed()) {
79 | opCtx->waitForConditionOrInterrupt(_prepareCommittedOrAbortedCond, lk, [&] {
80 | return _prepareCommitOrAbortCounter.loadRelaxed() > lastCount;
81 | });
82 | }
83 | }
84 |
85 | void RocksDurabilityManager::notifyPreparedUnitOfWorkHasCommittedOrAborted() {
86 | stdx::unique_lock lk(_prepareCommittedOrAbortedMutex);
87 | _prepareCommitOrAbortCounter.fetchAndAdd(1);
88 | _prepareCommittedOrAbortedCond.notify_all();
89 | }
90 | } // namespace mongo
91 |
--------------------------------------------------------------------------------
/src/rocks_index_test.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 MongoDB Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License, version 3,
6 | * as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | *
16 | * As a special exception, the copyright holders give permission to link the
17 | * code of portions of this program with the OpenSSL library under certain
18 | * conditions as described in each individual source file and distribute
19 | * linked combinations including the program with the OpenSSL library. You
20 | * must comply with the GNU Affero General Public License in all respects for
21 | * all of the code used other than as permitted herein. If you modify file(s)
22 | * with this exception, you may extend this exception to your version of the
23 | * file(s), but you are not obligated to do so. If you do not wish to do so,
24 | * delete this exception statement from your version. If you delete this
25 | * exception statement from all source files in the program, then also delete
26 | * it in the license file.
27 | */
28 |
29 | #include "mongo/platform/basic.h"
30 |
31 | #include
32 | #include
33 |
34 | #include
35 | #include
36 | #include
37 | #include
38 |
39 | #include "mongo/base/init.h"
40 | #include "mongo/db/concurrency/write_conflict_exception.h"
41 | #include "mongo/db/storage/sorted_data_interface_test_harness.h"
42 | #include "mongo/stdx/memory.h"
43 | #include "mongo/unittest/temp_dir.h"
44 | #include "mongo/unittest/unittest.h"
45 |
46 | #include "rocks_engine.h"
47 | #include "rocks_index.h"
48 | #include "rocks_recovery_unit.h"
49 | #include "rocks_snapshot_manager.h"
50 |
51 | namespace mongo {
52 | namespace {
53 |
54 | using std::string;
55 |
56 | class RocksIndexHarness final : public SortedDataInterfaceHarnessHelper {
57 | public:
58 | RocksIndexHarness()
59 | : _order(Ordering::make(BSONObj())),
60 | _dbpath("rocks_test"),
61 | _engine(_dbpath.path(), true /* durable */, 3 /* kRocksFormatVersion */,
62 | false /* readOnly */) {}
63 |
64 | virtual ~RocksIndexHarness() {}
65 |
66 | std::unique_ptr newSortedDataInterface(bool unique, bool partial) {
67 | BSONObjBuilder configBuilder;
68 | RocksIndexBase::generateConfig(&configBuilder, 3,
69 | IndexDescriptor::IndexVersion::kV2);
70 | if (unique) {
71 | return stdx::make_unique(
72 | _engine.getDB(), _engine.getDefaultCf_ForTest(), "prefix", "ident", _order,
73 | configBuilder.obj(), "test.rocks", "testIndex", BSONObj(), partial);
74 | } else {
75 | return stdx::make_unique(
76 | _engine.getDB(), _engine.getDefaultCf_ForTest(), "prefix", "ident", _order,
77 | configBuilder.obj());
78 | }
79 | }
80 |
81 | std::unique_ptr newRecoveryUnit() final {
82 | return stdx::make_unique(true /* durale */, &_engine);
83 | }
84 |
85 | private:
86 | Ordering _order;
87 | unittest::TempDir _dbpath;
88 | RocksEngine _engine;
89 | };
90 |
91 | std::unique_ptr makeHarnessHelper() {
92 | return stdx::make_unique();
93 | }
94 |
95 | MONGO_INITIALIZER(RegisterHarnessFactory)(InitializerContext* const) {
96 | mongo::registerHarnessHelperFactory(makeHarnessHelper);
97 | return Status::OK();
98 | }
99 |
100 | } // namespace
101 | } // namespace mongo
102 |
--------------------------------------------------------------------------------
/src/rocks_parameters.idl:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2018-present MongoDB, Inc.
2 | #
3 | # This program is free software: you can redistribute it and/or modify
4 | # it under the terms of the Server Side Public License, version 1,
5 | # as published by MongoDB, Inc.
6 | #
7 | # This program is distributed in the hope that it will be useful,
8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | # Server Side Public License for more details.
11 | #
12 | # You should have received a copy of the Server Side Public License
13 | # along with this program. If not, see
14 | # .
15 | #
16 | # As a special exception, the copyright holders give permission to link the
17 | # code of portions of this program with the OpenSSL library under certain
18 | # conditions as described in each individual source file and distribute
19 | # linked combinations including the program with the OpenSSL library. You
20 | # must comply with the Server Side Public License in all respects for
21 | # all of the code used other than as permitted herein. If you modify file(s)
22 | # with this exception, you may extend this exception to your version of the
23 | # file(s), but you are not obligated to do so. If you do not wish to do so,
24 | # delete this exception statement from your version. If you delete this
25 | # exception statement from all source files in the program, then also delete
26 | # it in the license file.
27 | #
28 |
29 | global:
30 | cpp_namespace: "mongo"
31 | cpp_includes:
32 | - "mongo/db/modules/rocks/src/rocks_engine.h"
33 | - "mongo/util/concurrency/ticketholder.h"
34 | - "mongo/util/debug_util.h"
35 |
36 | server_parameters:
37 | rocksConcurrentWriteTransactions:
38 | description: "Rocks Concurrent Write Transactions"
39 | set_at: [ startup, runtime ]
40 | cpp_class:
41 | name: ROpenWriteTransactionParam
42 | data: 'TicketHolder*'
43 | override_ctor: true
44 | rocksConcurrentReadTransactions:
45 | description: "Rocks Concurrent Read Transactions"
46 | set_at: [ startup, runtime ]
47 | cpp_class:
48 | name: ROpenReadTransactionParam
49 | data: 'TicketHolder*'
50 | override_ctor: true
51 |
52 | rocksdbRuntimeConfigMaxWriteMBPerSec:
53 | description: 'rate limiter to MB/s'
54 | set_at: [ startup, runtime ]
55 | cpp_class:
56 | name: RocksRateLimiterServerParameter
57 | data: 'RocksEngine*'
58 | override_set: true
59 | condition: { expr: false }
60 |
61 | rocksdbBackup:
62 | description: 'rocksdb backup'
63 | set_at: runtime
64 | cpp_class:
65 | name: RocksBackupServerParameter
66 | data: 'RocksEngine*'
67 | override_set: true
68 | condition: { expr: false }
69 |
70 | rocksdbCompact:
71 | description: 'rocksdb compact'
72 | set_at: runtime
73 | cpp_class:
74 | name: RocksCompactServerParameter
75 | data: 'RocksEngine*'
76 | override_set: true
77 | condition: { expr: false }
78 |
79 | rocksdbRuntimeConfigCacheSizeGB:
80 | description: 'rocks cache sizeGB'
81 | set_at: startup
82 | cpp_class:
83 | name: RocksCacheSizeParameter
84 | data: 'RocksEngine*'
85 | override_set: true
86 | condition: { expr: false }
87 |
88 | rocksdbOptions:
89 | description: 'set rocksdb options'
90 | set_at: [ startup, runtime ]
91 | cpp_class:
92 | name: RocksOptionsParameter
93 | data: 'RocksEngine*'
94 | override_set: true
95 | condition: { expr: false }
96 |
97 | minSSTFileCountReserved:
98 | description: 'delete oplogs until minSSTFileCountReserved files exceeds the total max size'
99 | set_at: [ startup, runtime ]
100 | cpp_class:
101 | name: ExportedMinSSTFileCountReservedParameter
102 | data: 'AtomicWord*'
103 | override_ctor: true
104 |
105 | rocksdbRuntimeConfigMaxConflictCheckSize:
106 | description: 'rocksdb max conflict check size'
107 | set_at: startup
108 | cpp_class:
109 | name: RocksdbMaxConflictCheckSizeParameter
110 | data: 'RocksEngine*'
111 | override_set: true
112 | condition: { expr: false }
113 |
--------------------------------------------------------------------------------
/src/rocks_begin_transaction_block.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2018 MongoDB Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License, version 3,
6 | * as published by the Free Software Foundation.
7 | *
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Affero General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Affero General Public License
15 | * along with this program. If not, see .
16 | *
17 | * As a special exception, the copyright holders give permission to link the
18 | * code of portions of this program with the OpenSSL library under certain
19 | * conditions as described in each individual source file and distribute
20 | * linked combinations including the program with the OpenSSL library. You
21 | * must comply with the GNU Affero General Public License in all respects for
22 | * all of the code used other than as permitted herein. If you modify file(s)
23 | * with this exception, you may extend this exception to your version of the
24 | * file(s), but you are not obligated to do so. If you do not wish to do so,
25 | * delete this exception statement from your version. If you delete this
26 | * exception statement from all source files in the program, then also delete
27 | * it in the license file.
28 | */
29 |
30 | #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kStorage
31 |
32 | #include "rocks_begin_transaction_block.h"
33 | #include
34 | #include "mongo/platform/basic.h"
35 | #include "mongo/util/log.h"
36 | #include "rocks_util.h"
37 |
38 | namespace mongo {
39 | RocksBeginTxnBlock::RocksBeginTxnBlock(rocksdb::TOTransactionDB* db,
40 | std::unique_ptr* txn,
41 | PrepareConflictBehavior prepareConflictBehavior,
42 | RoundUpPreparedTimestamps roundUpPreparedTimestamps,
43 | RoundUpReadTimestamp roundUpReadTimestamp)
44 | : _db(db) {
45 | invariant(!_rollback);
46 | rocksdb::WriteOptions wOpts;
47 | rocksdb::TOTransactionOptions txnOpts;
48 |
49 | if (prepareConflictBehavior == PrepareConflictBehavior::kIgnoreConflicts) {
50 | txnOpts.ignore_prepare = true;
51 | txnOpts.read_only = true;
52 | } else if (prepareConflictBehavior ==
53 | PrepareConflictBehavior::kIgnoreConflictsAllowWrites) {
54 | txnOpts.ignore_prepare = true;
55 | }
56 |
57 | if (roundUpPreparedTimestamps == RoundUpPreparedTimestamps::kRound) {
58 | txnOpts.timestamp_round_prepared = true;
59 | }
60 | if (roundUpReadTimestamp == RoundUpReadTimestamp::kRound) {
61 | txnOpts.timestamp_round_read = true;
62 | }
63 |
64 | _transaction = _db->BeginTransaction(wOpts, txnOpts);
65 | invariant(_transaction);
66 | txn->reset(_transaction);
67 | _rollback = true;
68 | }
69 |
70 | RocksBeginTxnBlock::~RocksBeginTxnBlock() {
71 | if (_rollback) {
72 | invariant(_transaction->Rollback().ok());
73 | }
74 | }
75 |
76 | Status RocksBeginTxnBlock::setReadSnapshot(Timestamp readTs) {
77 | invariant(_rollback);
78 | rocksdb::RocksTimeStamp ts(readTs.asULL());
79 | auto status = _transaction->SetReadTimeStamp(ts);
80 | if (!status.ok()) {
81 | if (status.IsInvalidArgument()) {
82 | return Status(ErrorCodes::SnapshotTooOld,
83 | str::stream() << "Read timestamp " << ts
84 | << " is older than the oldest available timestamp.");
85 | }
86 | return rocksToMongoStatus(status);
87 | }
88 |
89 | status = _transaction->GetReadTimeStamp(&ts);
90 | invariant(status.ok(), status.ToString());
91 | _readTimestamp = Timestamp(ts);
92 | return Status::OK();
93 | }
94 |
95 | void RocksBeginTxnBlock::done() {
96 | invariant(_rollback);
97 | _rollback = false;
98 | }
99 |
100 | Timestamp RocksBeginTxnBlock::getTimestamp() const {
101 | invariant(!_readTimestamp.isNull());
102 | return _readTimestamp;
103 | }
104 |
105 | } // namespace mongo
106 |
--------------------------------------------------------------------------------
/src/rocks_snapshot_manager.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 MongoDB Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License, version 3,
6 | * as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | *
16 | * As a special exception, the copyright holders give permission to link the
17 | * code of portions of this program with the OpenSSL library under certain
18 | * conditions as described in each individual source file and distribute
19 | * linked combinations including the program with the OpenSSL library. You
20 | * must comply with the GNU Affero General Public License in all respects for
21 | * all of the code used other than as permitted herein. If you modify file(s)
22 | * with this exception, you may extend this exception to your version of the
23 | * file(s), but you are not obligated to do so. If you do not wish to do so,
24 | * delete this exception statement from your version. If you delete this
25 | * exception statement from all source files in the program, then also delete
26 | * it in the license file.
27 | */
28 |
29 | #include
30 |
31 | #include
32 | #include "mongo/db/modules/rocks/src/totdb/totransaction.h"
33 | #include "mongo/db/modules/rocks/src/totdb/totransaction_db.h"
34 |
35 | #include "mongo/db/storage/recovery_unit.h"
36 | #include "mongo/db/storage/snapshot_manager.h"
37 | #include "mongo/platform/mutex.h"
38 |
39 | #include "rocks_begin_transaction_block.h"
40 |
41 | #pragma once
42 |
43 | namespace mongo {
44 |
45 | using RoundUpPreparedTimestamps = RocksBeginTxnBlock::RoundUpPreparedTimestamps;
46 |
47 | class RocksRecoveryUnit;
48 |
49 | class RocksSnapshotManager final : public SnapshotManager {
50 | RocksSnapshotManager(const RocksSnapshotManager&) = delete;
51 | RocksSnapshotManager& operator=(const RocksSnapshotManager&) = delete;
52 |
53 | public:
54 | RocksSnapshotManager() = default;
55 | virtual ~RocksSnapshotManager() {}
56 | void setCommittedSnapshot(const Timestamp& ts) final;
57 | void dropAllSnapshots() final;
58 | void setLocalSnapshot(const Timestamp& ts) final;
59 | boost::optional getLocalSnapshot() final;
60 |
61 | //
62 | // RocksDB-specific methods
63 | //
64 |
65 | /**
66 | * Starts a transaction and returns the SnapshotName used.
67 | *
68 | * Throws if there is currently no committed snapshot.
69 | */
70 | Timestamp beginTransactionOnCommittedSnapshot(
71 | rocksdb::TOTransactionDB* db, std::unique_ptr* txn,
72 | PrepareConflictBehavior prepareConflictBehavior,
73 | RoundUpPreparedTimestamps roundUpPreparedTimestamps) const;
74 |
75 | /**
76 | * Starts a transaction on the last stable local timestamp, set by setLocalSnapshot.
77 | *
78 | * Throws if no local snapshot has been set.
79 | */
80 | Timestamp beginTransactionOnLocalSnapshot(
81 | rocksdb::TOTransactionDB* db, std::unique_ptr* txn,
82 | PrepareConflictBehavior prepareConflictBehavior,
83 | RoundUpPreparedTimestamps roundUpPreparedTimestamps) const;
84 |
85 | /**
86 | * Returns lowest SnapshotName that could possibly be used by a future call to
87 | * beginTransactionOnCommittedSnapshot, or boost::none if there is currently no committed
88 | * snapshot.
89 | *
90 | * This should not be used for starting a transaction on this SnapshotName since the named
91 | * snapshot may be deleted by the time you start the transaction.
92 | */
93 | boost::optional getMinSnapshotForNextCommittedRead() const;
94 |
95 | private:
96 | // Snapshot to use for reads at a commit timestamp.
97 | mutable Mutex _committedSnapshotMutex = // Guards _committedSnapshot.
98 | MONGO_MAKE_LATCH("RocksSnapshotManager::_committedSnapshotMutex");
99 | boost::optional _committedSnapshot;
100 |
101 | // Snapshot to use for reads at a local stable timestamp.
102 | mutable Mutex _localSnapshotMutex = // Guards _localSnapshot.
103 | MONGO_MAKE_LATCH("RocksSnapshotManager::_localSnapshotMutex");
104 | boost::optional _localSnapshot;
105 | };
106 | } // namespace mongo
107 |
--------------------------------------------------------------------------------
/src/rocks_durability_manager.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 MongoDB Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License, version 3,
6 | * as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | *
16 | * As a special exception, the copyright holders give permission to link the
17 | * code of portions of this program with the OpenSSL library under certain
18 | * conditions as described in each individual source file and distribute
19 | * linked combinations including the program with the OpenSSL library. You
20 | * must comply with the GNU Affero General Public License in all respects for
21 | * all of the code used other than as permitted herein. If you modify file(s)
22 | * with this exception, you may extend this exception to your version of the
23 | * file(s), but you are not obligated to do so. If you do not wish to do so,
24 | * delete this exception statement from your version. If you delete this
25 | * exception statement from all source files in the program, then also delete
26 | * it in the license file.
27 | */
28 |
29 | #pragma once
30 |
31 | #include "mongo/db/operation_context.h"
32 | #include "mongo/platform/basic.h"
33 | #include "mongo/stdx/condition_variable.h"
34 |
35 | namespace rocksdb {
36 | class DB;
37 | }
38 |
39 | namespace mongo {
40 |
41 | class JournalListener;
42 |
43 | class RocksDurabilityManager {
44 | RocksDurabilityManager(const RocksDurabilityManager&) = delete;
45 | RocksDurabilityManager& operator=(const RocksDurabilityManager&) = delete;
46 |
47 | public:
48 | RocksDurabilityManager(rocksdb::DB* db, bool durable,
49 | rocksdb::ColumnFamilyHandle* defaultCf,
50 | rocksdb::ColumnFamilyHandle* oplogCf);
51 |
52 | void setJournalListener(JournalListener* jl);
53 |
54 | void waitUntilDurable(bool forceFlush);
55 |
56 | /**
57 | * Waits until a prepared unit of work has ended (either been commited or aborted). This
58 | * should be used when encountering ROCKS_PREPARE_CONFLICT errors. The caller is required to
59 | * retry the conflicting WiredTiger API operation. A return from this function does not
60 | * guarantee that the conflicting transaction has ended, only that one prepared unit of work
61 | * in the process has signaled that it has ended. Accepts an OperationContext that will
62 | * throw an AssertionException when interrupted.
63 | *
64 | * This method is provided in RocksDurabilityManager and not RecoveryUnit because all
65 | * recovery units share the same RocksDurabilityManager, and we want a recovery unit on one
66 | * thread to signal all recovery units waiting for prepare conflicts across all other
67 | * threads.
68 | */
69 | void waitUntilPreparedUnitOfWorkCommitsOrAborts(OperationContext* opCtx,
70 | uint64_t lastCount);
71 |
72 | /**
73 | * Notifies waiters that the caller's perpared unit of work has ended
74 | * (either committed or aborted).
75 | */
76 | void notifyPreparedUnitOfWorkHasCommittedOrAborted();
77 |
78 | std::uint64_t getPrepareCommitOrAbortCount() const {
79 | return _prepareCommitOrAbortCounter.loadRelaxed();
80 | }
81 |
82 | private:
83 | rocksdb::DB* _db; // not owned
84 |
85 | bool _durable;
86 | rocksdb::ColumnFamilyHandle* _defaultCf; // not owned
87 | rocksdb::ColumnFamilyHandle* _oplogCf; // not owned
88 | // Notified when we commit to the journal.
89 | JournalListener* _journalListener;
90 |
91 | // Protects _journalListener.
92 | Mutex _journalListenerMutex =
93 | MONGO_MAKE_LATCH("RocksDurabilityManager::_journalListenerMutex");
94 | AtomicWord _lastSyncTime;
95 | Mutex _lastSyncMutex = MONGO_MAKE_LATCH("RocksDurabilityManager::_lastSyncMutex");
96 |
97 | // Mutex and cond var for waiting on prepare commit or abort.
98 | Mutex _prepareCommittedOrAbortedMutex =
99 | MONGO_MAKE_LATCH("RocksDurabilityManager::_prepareCommittedOrAbortedMutex");
100 |
101 | stdx::condition_variable _prepareCommittedOrAbortedCond;
102 |
103 | AtomicWord _prepareCommitOrAbortCounter{0};
104 | };
105 | } // namespace mongo
106 |
--------------------------------------------------------------------------------
/src/rocks_counter_manager.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2014 MongoDB Inc.
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU Affero General Public License, version 3,
6 | * as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU Affero General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU Affero General Public License
14 | * along with this program. If not, see .
15 | *
16 | * As a special exception, the copyright holders give permission to link the
17 | * code of portions of this program with the OpenSSL library under certain
18 | * conditions as described in each individual source file and distribute
19 | * linked combinations including the program with the OpenSSL library. You
20 | * must comply with the GNU Affero General Public License in all respects for
21 | * all of the code used other than as permitted herein. If you modify file(s)
22 | * with this exception, you may extend this exception to your version of the
23 | * file(s), but you are not obligated to do so. If you do not wish to do so,
24 | * delete this exception statement from your version. If you delete this
25 | * exception statement from all source files in the program, then also delete
26 | * it in the license file.
27 | */
28 |
29 | #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kStorage
30 |
31 | #include "mongo/platform/basic.h"
32 | #include "mongo/platform/endian.h"
33 |
34 | #include "rocks_counter_manager.h"
35 |
36 | #include
37 | #include