diff --git a/Builds/CMake/RippledCore.cmake b/Builds/CMake/RippledCore.cmake index 18f85b0b9..bf24760b0 100644 --- a/Builds/CMake/RippledCore.cmake +++ b/Builds/CMake/RippledCore.cmake @@ -538,7 +538,7 @@ target_sources (rippled PRIVATE subdir: nodestore #]===============================] src/ripple/nodestore/backend/CassandraFactory.cpp - src/ripple/nodestore/backend/MemDBFactory.cpp + src/ripple/nodestore/backend/RWDBFactory.cpp src/ripple/nodestore/backend/MemoryFactory.cpp src/ripple/nodestore/backend/FlatmapFactory.cpp src/ripple/nodestore/backend/NuDBFactory.cpp diff --git a/cfg/rippled-example.cfg b/cfg/rippled-example.cfg index 0a6693130..41fe12158 100644 --- a/cfg/rippled-example.cfg +++ b/cfg/rippled-example.cfg @@ -1056,7 +1056,18 @@ # Cassandra is an alternative backend to be used only with Reporting Mode. # See the Reporting Mode section for more details about Reporting Mode. # -# Required keys for NuDB and RocksDB: +# type = RWDB +# +# RWDB is a high-performance memory store written by XRPL-Labs and optimized +# for xahaud. RWDB is NOT persistent and the data will be lost on restart. +# RWDB is recommended for Validator and Peer nodes that are not required to +# store history. +# +# RWDB maintains its high speed regardless of the amount of history +# stored. Online delete should NOT be used instead RWDB will use the +# ledger_history config value to determine how many ledgers to keep in memory. +# +# Required keys for NuDB, RWDB and RocksDB: # # path Location to store the database # @@ -1112,7 +1123,8 @@ # online_delete Minimum value of 256. Enable automatic purging # of older ledger information. Maintain at least this # number of ledger records online. Must be greater -# than or equal to ledger_history. +# than or equal to ledger_history. If using RWDB +# this value is ignored. # # These keys modify the behavior of online_delete, and thus are only # relevant if online_delete is defined and non-zero: diff --git a/src/ripple/app/rdb/backend/MemoryDatabase.h b/src/ripple/app/rdb/backend/RWDBDatabase.h similarity index 98% rename from src/ripple/app/rdb/backend/MemoryDatabase.h rename to src/ripple/app/rdb/backend/RWDBDatabase.h index c75e5d8e3..0a84f48ce 100644 --- a/src/ripple/app/rdb/backend/MemoryDatabase.h +++ b/src/ripple/app/rdb/backend/RWDBDatabase.h @@ -14,7 +14,7 @@ namespace ripple { -class MemoryDatabase : public SQLiteDatabase +class RWDBDatabase : public SQLiteDatabase { private: struct LedgerData @@ -31,8 +31,6 @@ private: }; Application& app_; - Config const& config_; - JobQueue& jobQueue_; mutable std::shared_mutex mutex_; @@ -42,8 +40,8 @@ private: std::map accountTxMap_; public: - MemoryDatabase(Application& app, Config const& config, JobQueue& jobQueue) - : app_(app), config_(config), jobQueue_(jobQueue) + RWDBDatabase(Application& app, Config const& config, JobQueue& jobQueue) + : app_(app) { } @@ -568,7 +566,7 @@ public: // No-op for in-memory database } - ~MemoryDatabase() + ~RWDBDatabase() { // Regular maps can use standard clear accountTxMap_.clear(); @@ -957,9 +955,9 @@ public: // Factory function std::unique_ptr -getMemoryDatabase(Application& app, Config const& config, JobQueue& jobQueue) +getRWDBDatabase(Application& app, Config const& config, JobQueue& jobQueue) { - return std::make_unique(app, config, jobQueue); + return std::make_unique(app, config, jobQueue); } } // namespace ripple diff --git a/src/ripple/app/rdb/impl/RelationalDatabase.cpp b/src/ripple/app/rdb/impl/RelationalDatabase.cpp index 2b0625e6c..64161bd53 100644 --- a/src/ripple/app/rdb/impl/RelationalDatabase.cpp +++ b/src/ripple/app/rdb/impl/RelationalDatabase.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include @@ -40,7 +40,7 @@ RelationalDatabase::init( { bool use_sqlite = false; bool use_postgres = false; - bool use_memdb = false; + bool use_rwdb = false; bool use_flatmap = false; if (config.reporting()) @@ -56,9 +56,9 @@ RelationalDatabase::init( { use_sqlite = true; } - else if (boost::iequals(get(rdb_section, "backend"), "memdb")) + else if (boost::iequals(get(rdb_section, "backend"), "rwdb")) { - use_memdb = true; + use_rwdb = true; } else if (boost::iequals(get(rdb_section, "backend"), "flatmap")) { @@ -85,9 +85,9 @@ RelationalDatabase::init( { return getPostgresDatabase(app, config, jobQueue); } - else if (use_memdb) + else if (use_rwdb) { - return getMemoryDatabase(app, config, jobQueue); + return getRWDBDatabase(app, config, jobQueue); } else if (use_flatmap) { diff --git a/src/ripple/core/Config.h b/src/ripple/core/Config.h index 604baf8a3..2779547e2 100644 --- a/src/ripple/core/Config.h +++ b/src/ripple/core/Config.h @@ -357,9 +357,9 @@ public: static bool const isMem = (!section(SECTION_RELATIONAL_DB).empty() && boost::beast::iequals( - get(section(SECTION_RELATIONAL_DB), "backend"), "memdb")) || + get(section(SECTION_RELATIONAL_DB), "backend"), "rwdb")) || (!section("node_db").empty() && - (boost::beast::iequals(get(section("node_db"), "type"), "memdb") || + (boost::beast::iequals(get(section("node_db"), "type"), "rwdb") || boost::beast::iequals( get(section("node_db"), "type"), "flatmap"))); // RHNOTE: memory type is not selected for here because it breaks diff --git a/src/ripple/nodestore/backend/MemDBFactory.cpp b/src/ripple/nodestore/backend/RWDBFactory.cpp similarity index 94% rename from src/ripple/nodestore/backend/MemDBFactory.cpp rename to src/ripple/nodestore/backend/RWDBFactory.cpp index aa354cf76..3f700038b 100644 --- a/src/ripple/nodestore/backend/MemDBFactory.cpp +++ b/src/ripple/nodestore/backend/RWDBFactory.cpp @@ -13,7 +13,7 @@ namespace ripple { namespace NodeStore { -class MemDBBackend : public Backend +class RWDBBackend : public Backend { private: std::string name_; @@ -40,7 +40,7 @@ private: DataStore table_; public: - MemDBBackend( + RWDBBackend( size_t keyBytes, Section const& keyValues, beast::Journal journal) @@ -51,7 +51,7 @@ public: name_ = "node_db"; } - ~MemDBBackend() override + ~RWDBBackend() override { close(); } @@ -205,15 +205,15 @@ private: } }; -class MemDBFactory : public Factory +class RWDBFactory : public Factory { public: - MemDBFactory() + RWDBFactory() { Manager::instance().insert(*this); } - ~MemDBFactory() override + ~RWDBFactory() override { Manager::instance().erase(*this); } @@ -221,7 +221,7 @@ public: std::string getName() const override { - return "MemDB"; + return "RWDB"; } std::unique_ptr @@ -232,9 +232,11 @@ public: Scheduler& scheduler, beast::Journal journal) override { - return std::make_unique(keyBytes, keyValues, journal); + return std::make_unique(keyBytes, keyValues, journal); } }; +static RWDBFactory rwDBFactory; + } // namespace NodeStore } // namespace ripple diff --git a/src/ripple/overlay/impl/OverlayImpl.cpp b/src/ripple/overlay/impl/OverlayImpl.cpp index 3e0e68e87..b1027826f 100644 --- a/src/ripple/overlay/impl/OverlayImpl.cpp +++ b/src/ripple/overlay/impl/OverlayImpl.cpp @@ -141,7 +141,7 @@ OverlayImpl::OverlayImpl( app.config().section(SECTION_RELATIONAL_DB).empty() || !boost::iequals( get(app.config().section(SECTION_RELATIONAL_DB), "backend"), - "memory"))) + "rwdb"))) , m_resolver(resolver) , next_id_(1) , timer_count_(0) diff --git a/src/test/nodestore/Backend_test.cpp b/src/test/nodestore/Backend_test.cpp index ef6b99c99..10ba4e4ad 100644 --- a/src/test/nodestore/Backend_test.cpp +++ b/src/test/nodestore/Backend_test.cpp @@ -82,8 +82,8 @@ public: } } - // Memory backend does not keep table/data after close - if (type != "memory") + // rwdb backend does not keep table/data after close + if (type != "rwdb") { // Re-open the backend std::unique_ptr backend = Manager::instance().make_Backend( @@ -108,7 +108,7 @@ public: std::uint64_t const seedValue = 50; testBackend("memory", seedValue); - testBackend("memdb", seedValue); + testBackend("rwdb", seedValue); testBackend("nudb", seedValue); #if RIPPLE_ROCKSDB_AVAILABLE diff --git a/src/test/nodestore/Database_test.cpp b/src/test/nodestore/Database_test.cpp index 87ae5b148..80c0808bb 100644 --- a/src/test/nodestore/Database_test.cpp +++ b/src/test/nodestore/Database_test.cpp @@ -661,7 +661,7 @@ public: testNodeStore("memory", false, seedValue); - testNodeStore("memdb", false, seedValue); + testNodeStore("rwdb", false, seedValue); // Persistent backend tests {