mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Remove temp_db (RIPD-887)
This commit is contained in:
@@ -661,7 +661,6 @@
|
|||||||
# migrate the specified database into the current database given
|
# migrate the specified database into the current database given
|
||||||
# in the [node_db] section.
|
# in the [node_db] section.
|
||||||
#
|
#
|
||||||
# [temp_db] Settings for the look-aside temporary db (optional)
|
|
||||||
# [import_db] Settings for performing a one-time import (optional)
|
# [import_db] Settings for performing a one-time import (optional)
|
||||||
# [database_path] Path to the book-keeping databases.
|
# [database_path] Path to the book-keeping databases.
|
||||||
#
|
#
|
||||||
@@ -671,7 +670,6 @@
|
|||||||
# rippled.cfg file. Partial pathnames will be considered relative to
|
# rippled.cfg file. Partial pathnames will be considered relative to
|
||||||
# the location of the rippled executable.
|
# the location of the rippled executable.
|
||||||
#
|
#
|
||||||
# The [temp_db] configuration setting is deprecated and should be avoided.
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -168,7 +168,6 @@ setupConfigForUnitTests (Config& config)
|
|||||||
config.overwrite (ConfigSection::nodeDatabase (), "type", "memory");
|
config.overwrite (ConfigSection::nodeDatabase (), "type", "memory");
|
||||||
config.overwrite (ConfigSection::nodeDatabase (), "path", "main");
|
config.overwrite (ConfigSection::nodeDatabase (), "path", "main");
|
||||||
|
|
||||||
config.deprecatedClearSection (ConfigSection::tempNodeDatabase ());
|
|
||||||
config.deprecatedClearSection (ConfigSection::importNodeDatabase ());
|
config.deprecatedClearSection (ConfigSection::importNodeDatabase ());
|
||||||
config.legacy("database_path", "DummyForUnitTests");
|
config.legacy("database_path", "DummyForUnitTests");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ public:
|
|||||||
bool advisoryDelete = false;
|
bool advisoryDelete = false;
|
||||||
std::uint32_t ledgerHistory = 0;
|
std::uint32_t ledgerHistory = 0;
|
||||||
Section nodeDatabase;
|
Section nodeDatabase;
|
||||||
Section ephemeralNodeDatabase;
|
|
||||||
std::string databasePath;
|
std::string databasePath;
|
||||||
std::uint32_t deleteBatch = 100;
|
std::uint32_t deleteBatch = 100;
|
||||||
std::uint32_t backOff = 100;
|
std::uint32_t backOff = 100;
|
||||||
|
|||||||
@@ -227,8 +227,7 @@ SHAMapStoreImp::makeDatabase (std::string const& name,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
db = NodeStore::Manager::instance().make_Database (name, scheduler_, nodeStoreJournal_,
|
db = NodeStore::Manager::instance().make_Database (name, scheduler_, nodeStoreJournal_,
|
||||||
readThreads, setup_.nodeDatabase,
|
readThreads, setup_.nodeDatabase);
|
||||||
setup_.ephemeralNodeDatabase);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return db;
|
return db;
|
||||||
@@ -492,14 +491,8 @@ SHAMapStoreImp::makeDatabaseRotating (std::string const& name,
|
|||||||
std::shared_ptr <NodeStore::Backend> writableBackend,
|
std::shared_ptr <NodeStore::Backend> writableBackend,
|
||||||
std::shared_ptr <NodeStore::Backend> archiveBackend) const
|
std::shared_ptr <NodeStore::Backend> archiveBackend) const
|
||||||
{
|
{
|
||||||
std::unique_ptr <NodeStore::Backend> fastBackend (
|
|
||||||
(setup_.ephemeralNodeDatabase.size() > 0)
|
|
||||||
? NodeStore::Manager::instance().make_Backend (setup_.ephemeralNodeDatabase,
|
|
||||||
scheduler_, journal_) : nullptr);
|
|
||||||
|
|
||||||
return NodeStore::Manager::instance().make_DatabaseRotating ("NodeStore.main", scheduler_,
|
return NodeStore::Manager::instance().make_DatabaseRotating ("NodeStore.main", scheduler_,
|
||||||
readThreads, writableBackend, archiveBackend,
|
readThreads, writableBackend, archiveBackend, nodeStoreJournal_);
|
||||||
std::move (fastBackend), nodeStoreJournal_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -680,7 +673,6 @@ setup_SHAMapStore (Config const& c)
|
|||||||
|
|
||||||
setup.ledgerHistory = c.LEDGER_HISTORY;
|
setup.ledgerHistory = c.LEDGER_HISTORY;
|
||||||
setup.nodeDatabase = c[ConfigSection::nodeDatabase ()];
|
setup.nodeDatabase = c[ConfigSection::nodeDatabase ()];
|
||||||
setup.ephemeralNodeDatabase = c[ConfigSection::tempNodeDatabase ()];
|
|
||||||
setup.databasePath = c.legacy("database_path");
|
setup.databasePath = c.legacy("database_path");
|
||||||
|
|
||||||
get_if_exists (sec, "delete_batch", setup.deleteBatch);
|
get_if_exists (sec, "delete_batch", setup.deleteBatch);
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ namespace ripple {
|
|||||||
struct ConfigSection
|
struct ConfigSection
|
||||||
{
|
{
|
||||||
static std::string nodeDatabase () { return "node_db"; }
|
static std::string nodeDatabase () { return "node_db"; }
|
||||||
static std::string tempNodeDatabase () { return "temp_db"; }
|
|
||||||
static std::string importNodeDatabase () { return "import_db"; }
|
static std::string importNodeDatabase () { return "import_db"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -87,8 +87,7 @@ public:
|
|||||||
std::unique_ptr <Database>
|
std::unique_ptr <Database>
|
||||||
make_Database (std::string const& name, Scheduler& scheduler,
|
make_Database (std::string const& name, Scheduler& scheduler,
|
||||||
beast::Journal journal, int readThreads,
|
beast::Journal journal, int readThreads,
|
||||||
Section const& backendParameters,
|
Section const& backendParameters) = 0;
|
||||||
Section fastBackendParameters = Section()) = 0;
|
|
||||||
|
|
||||||
virtual
|
virtual
|
||||||
std::unique_ptr <DatabaseRotating>
|
std::unique_ptr <DatabaseRotating>
|
||||||
@@ -96,7 +95,6 @@ public:
|
|||||||
Scheduler& scheduler, std::int32_t readThreads,
|
Scheduler& scheduler, std::int32_t readThreads,
|
||||||
std::shared_ptr <Backend> writableBackend,
|
std::shared_ptr <Backend> writableBackend,
|
||||||
std::shared_ptr <Backend> archiveBackend,
|
std::shared_ptr <Backend> archiveBackend,
|
||||||
std::unique_ptr <Backend> fastBackend,
|
|
||||||
beast::Journal journal) = 0;
|
beast::Journal journal) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -45,8 +45,6 @@ private:
|
|||||||
Scheduler& m_scheduler;
|
Scheduler& m_scheduler;
|
||||||
// Persistent key/value storage.
|
// Persistent key/value storage.
|
||||||
std::unique_ptr <Backend> m_backend;
|
std::unique_ptr <Backend> m_backend;
|
||||||
// Larger key/value storage, but not necessarily persistent.
|
|
||||||
std::unique_ptr <Backend> m_fastBackend;
|
|
||||||
protected:
|
protected:
|
||||||
// Positive cache
|
// Positive cache
|
||||||
TaggedCache <uint256, NodeObject> m_cache;
|
TaggedCache <uint256, NodeObject> m_cache;
|
||||||
@@ -67,12 +65,10 @@ public:
|
|||||||
Scheduler& scheduler,
|
Scheduler& scheduler,
|
||||||
int readThreads,
|
int readThreads,
|
||||||
std::unique_ptr <Backend> backend,
|
std::unique_ptr <Backend> backend,
|
||||||
std::unique_ptr <Backend> fastBackend,
|
|
||||||
beast::Journal journal)
|
beast::Journal journal)
|
||||||
: m_journal (journal)
|
: m_journal (journal)
|
||||||
, m_scheduler (scheduler)
|
, m_scheduler (scheduler)
|
||||||
, m_backend (std::move (backend))
|
, m_backend (std::move (backend))
|
||||||
, m_fastBackend (std::move (fastBackend))
|
|
||||||
, m_cache ("NodeStore", cacheTargetSize, cacheTargetSeconds,
|
, m_cache ("NodeStore", cacheTargetSize, cacheTargetSeconds,
|
||||||
get_seconds_clock (), deprecatedLogs().journal("TaggedCache"))
|
get_seconds_clock (), deprecatedLogs().journal("TaggedCache"))
|
||||||
, m_negCache ("NodeStore", get_seconds_clock (),
|
, m_negCache ("NodeStore", get_seconds_clock (),
|
||||||
@@ -117,11 +113,6 @@ public:
|
|||||||
m_backend->close();
|
m_backend->close();
|
||||||
m_backend = nullptr;
|
m_backend = nullptr;
|
||||||
}
|
}
|
||||||
if (m_fastBackend)
|
|
||||||
{
|
|
||||||
m_fastBackend->close();
|
|
||||||
m_fastBackend = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -204,20 +195,8 @@ public:
|
|||||||
|
|
||||||
// Check the database(s).
|
// Check the database(s).
|
||||||
|
|
||||||
bool foundInFastBackend = false;
|
|
||||||
report.wentToDisk = true;
|
report.wentToDisk = true;
|
||||||
|
|
||||||
// Check the fast backend database if we have one
|
|
||||||
//
|
|
||||||
if (m_fastBackend != nullptr)
|
|
||||||
{
|
|
||||||
obj = fetchInternal (*m_fastBackend, hash);
|
|
||||||
|
|
||||||
// If we found the object, avoid storing it again later.
|
|
||||||
if (obj != nullptr)
|
|
||||||
foundInFastBackend = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Are we still without an object?
|
// Are we still without an object?
|
||||||
//
|
//
|
||||||
if (obj == nullptr)
|
if (obj == nullptr)
|
||||||
@@ -246,23 +225,10 @@ public:
|
|||||||
//
|
//
|
||||||
m_cache.canonicalize (hash, obj);
|
m_cache.canonicalize (hash, obj);
|
||||||
|
|
||||||
if (! foundInFastBackend)
|
// Since this was a 'hard' fetch, we will log it.
|
||||||
{
|
//
|
||||||
// If we have a fast back end, store it there for later.
|
if (m_journal.trace) m_journal.trace <<
|
||||||
//
|
"HOS: " << hash << " fetch: in db";
|
||||||
if (m_fastBackend != nullptr)
|
|
||||||
{
|
|
||||||
m_fastBackend->store (obj);
|
|
||||||
++m_storeCount;
|
|
||||||
if (obj)
|
|
||||||
m_storeSize += obj->getData().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Since this was a 'hard' fetch, we will log it.
|
|
||||||
//
|
|
||||||
if (m_journal.trace) m_journal.trace <<
|
|
||||||
"HOS: " << hash << " fetch: in db";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
@@ -334,14 +300,6 @@ public:
|
|||||||
m_storeSize += object->getData().size();
|
m_storeSize += object->getData().size();
|
||||||
|
|
||||||
m_negCache.erase (hash);
|
m_negCache.erase (hash);
|
||||||
|
|
||||||
if (m_fastBackend)
|
|
||||||
{
|
|
||||||
m_fastBackend->store (object);
|
|
||||||
++m_storeCount;
|
|
||||||
if (object)
|
|
||||||
m_storeSize += object->getData().size();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -52,11 +52,9 @@ public:
|
|||||||
int readThreads,
|
int readThreads,
|
||||||
std::shared_ptr <Backend> writableBackend,
|
std::shared_ptr <Backend> writableBackend,
|
||||||
std::shared_ptr <Backend> archiveBackend,
|
std::shared_ptr <Backend> archiveBackend,
|
||||||
std::unique_ptr <Backend> fastBackend,
|
|
||||||
beast::Journal journal)
|
beast::Journal journal)
|
||||||
: DatabaseImp (name, scheduler, readThreads,
|
: DatabaseImp (name, scheduler, readThreads,
|
||||||
std::unique_ptr <Backend>(), std::move (fastBackend),
|
std::unique_ptr <Backend>(), journal)
|
||||||
journal)
|
|
||||||
, writableBackend_ (writableBackend)
|
, writableBackend_ (writableBackend)
|
||||||
, archiveBackend_ (archiveBackend)
|
, archiveBackend_ (archiveBackend)
|
||||||
{}
|
{}
|
||||||
|
|||||||
@@ -91,19 +91,13 @@ ManagerImp::make_Database (
|
|||||||
Scheduler& scheduler,
|
Scheduler& scheduler,
|
||||||
beast::Journal journal,
|
beast::Journal journal,
|
||||||
int readThreads,
|
int readThreads,
|
||||||
Section const& backendParameters,
|
Section const& backendParameters)
|
||||||
Section fastBackendParameters)
|
|
||||||
{
|
{
|
||||||
std::unique_ptr <Backend> backend (make_Backend (
|
std::unique_ptr <Backend> backend (make_Backend (
|
||||||
backendParameters, scheduler, journal));
|
backendParameters, scheduler, journal));
|
||||||
|
|
||||||
std::unique_ptr <Backend> fastBackend (
|
|
||||||
(fastBackendParameters.size () > 0)
|
|
||||||
? make_Backend (fastBackendParameters, scheduler, journal)
|
|
||||||
: nullptr);
|
|
||||||
|
|
||||||
return std::make_unique <DatabaseImp> (name, scheduler, readThreads,
|
return std::make_unique <DatabaseImp> (name, scheduler, readThreads,
|
||||||
std::move (backend), std::move (fastBackend), journal);
|
std::move (backend), journal);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr <DatabaseRotating>
|
std::unique_ptr <DatabaseRotating>
|
||||||
@@ -113,12 +107,10 @@ ManagerImp::make_DatabaseRotating (
|
|||||||
std::int32_t readThreads,
|
std::int32_t readThreads,
|
||||||
std::shared_ptr <Backend> writableBackend,
|
std::shared_ptr <Backend> writableBackend,
|
||||||
std::shared_ptr <Backend> archiveBackend,
|
std::shared_ptr <Backend> archiveBackend,
|
||||||
std::unique_ptr <Backend> fastBackend,
|
|
||||||
beast::Journal journal)
|
beast::Journal journal)
|
||||||
{
|
{
|
||||||
return std::make_unique <DatabaseRotatingImp> (name, scheduler,
|
return std::make_unique <DatabaseRotatingImp> (name, scheduler,
|
||||||
readThreads, writableBackend, archiveBackend,
|
readThreads, writableBackend, archiveBackend, journal);
|
||||||
std::move (fastBackend), journal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Factory*
|
Factory*
|
||||||
|
|||||||
@@ -67,8 +67,7 @@ public:
|
|||||||
Scheduler& scheduler,
|
Scheduler& scheduler,
|
||||||
beast::Journal journal,
|
beast::Journal journal,
|
||||||
int readThreads,
|
int readThreads,
|
||||||
Section const& backendParameters,
|
Section const& backendParameters) override;
|
||||||
Section fastBackendParameters) override;
|
|
||||||
|
|
||||||
std::unique_ptr <DatabaseRotating>
|
std::unique_ptr <DatabaseRotating>
|
||||||
make_DatabaseRotating (
|
make_DatabaseRotating (
|
||||||
@@ -77,7 +76,6 @@ public:
|
|||||||
std::int32_t readThreads,
|
std::int32_t readThreads,
|
||||||
std::shared_ptr <Backend> writableBackend,
|
std::shared_ptr <Backend> writableBackend,
|
||||||
std::shared_ptr <Backend> archiveBackend,
|
std::shared_ptr <Backend> archiveBackend,
|
||||||
std::unique_ptr <Backend> fastBackend,
|
|
||||||
beast::Journal journal) override;
|
beast::Journal journal) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,6 @@ public:
|
|||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|
||||||
void testNodeStore (std::string const& type,
|
void testNodeStore (std::string const& type,
|
||||||
bool const useEphemeralDatabase,
|
|
||||||
bool const testPersistence,
|
bool const testPersistence,
|
||||||
std::int64_t const seedValue,
|
std::int64_t const seedValue,
|
||||||
int numObjectsToTest = 2000)
|
int numObjectsToTest = 2000)
|
||||||
@@ -95,8 +94,6 @@ public:
|
|||||||
DummyScheduler scheduler;
|
DummyScheduler scheduler;
|
||||||
|
|
||||||
std::string s = "NodeStore backend '" + type + "'";
|
std::string s = "NodeStore backend '" + type + "'";
|
||||||
if (useEphemeralDatabase)
|
|
||||||
s += " (with ephemeral database)";
|
|
||||||
|
|
||||||
testcase (s);
|
testcase (s);
|
||||||
|
|
||||||
@@ -105,14 +102,6 @@ public:
|
|||||||
nodeParams.set ("type", type);
|
nodeParams.set ("type", type);
|
||||||
nodeParams.set ("path", node_db.getFullPathName ().toStdString ());
|
nodeParams.set ("path", node_db.getFullPathName ().toStdString ());
|
||||||
|
|
||||||
beast::UnitTestUtilities::TempDirectory temp_db ("temp_db");
|
|
||||||
Section tempParams;
|
|
||||||
if (useEphemeralDatabase)
|
|
||||||
{
|
|
||||||
tempParams.set ("type", type);
|
|
||||||
tempParams.set ("path", temp_db.getFullPathName ().toStdString ());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a batch
|
// Create a batch
|
||||||
Batch batch;
|
Batch batch;
|
||||||
createPredictableBatch (batch, numObjectsToTest, seedValue);
|
createPredictableBatch (batch, numObjectsToTest, seedValue);
|
||||||
@@ -122,7 +111,7 @@ public:
|
|||||||
{
|
{
|
||||||
// Open the database
|
// Open the database
|
||||||
std::unique_ptr <Database> db = Manager::instance().make_Database (
|
std::unique_ptr <Database> db = Manager::instance().make_Database (
|
||||||
"test", scheduler, j, 2, nodeParams, tempParams);
|
"test", scheduler, j, 2, nodeParams);
|
||||||
|
|
||||||
// Write the batch
|
// Write the batch
|
||||||
storeBatch (*db, batch);
|
storeBatch (*db, batch);
|
||||||
@@ -159,37 +148,17 @@ public:
|
|||||||
std::sort (copy.begin (), copy.end (), NodeObject::LessThan ());
|
std::sort (copy.begin (), copy.end (), NodeObject::LessThan ());
|
||||||
expect (areBatchesEqual (batch, copy), "Should be equal");
|
expect (areBatchesEqual (batch, copy), "Should be equal");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useEphemeralDatabase)
|
|
||||||
{
|
|
||||||
// Verify the ephemeral db
|
|
||||||
std::unique_ptr <Database> db = Manager::instance().make_Database ("test",
|
|
||||||
scheduler, j, 2, tempParams, Section ());
|
|
||||||
|
|
||||||
// Read it back in
|
|
||||||
Batch copy;
|
|
||||||
fetchCopyOfBatch (*db, ©, batch);
|
|
||||||
|
|
||||||
// Canonicalize the source and destination batches
|
|
||||||
std::sort (batch.begin (), batch.end (), NodeObject::LessThan ());
|
|
||||||
std::sort (copy.begin (), copy.end (), NodeObject::LessThan ());
|
|
||||||
expect (areBatchesEqual (batch, copy), "Should be equal");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|
||||||
void runBackendTests (bool useEphemeralDatabase, std::int64_t const seedValue)
|
void runBackendTests (std::int64_t const seedValue)
|
||||||
{
|
{
|
||||||
testNodeStore ("nudb", useEphemeralDatabase, true, seedValue);
|
testNodeStore ("nudb", true, seedValue);
|
||||||
|
|
||||||
#if RIPPLE_ROCKSDB_AVAILABLE
|
#if RIPPLE_ROCKSDB_AVAILABLE
|
||||||
testNodeStore ("rocksdb", useEphemeralDatabase, true, seedValue);
|
testNodeStore ("rocksdb", true, seedValue);
|
||||||
#endif
|
|
||||||
|
|
||||||
#if RIPPLE_ENABLE_SQLITE_BACKEND_TESTS
|
|
||||||
testNodeStore ("sqlite", useEphemeralDatabase, true, seedValue);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,11 +183,9 @@ public:
|
|||||||
{
|
{
|
||||||
std::int64_t const seedValue = 50;
|
std::int64_t const seedValue = 50;
|
||||||
|
|
||||||
testNodeStore ("memory", false, false, seedValue);
|
testNodeStore ("memory", false, seedValue);
|
||||||
|
|
||||||
runBackendTests (false, seedValue);
|
runBackendTests (seedValue);
|
||||||
|
|
||||||
runBackendTests (true, seedValue);
|
|
||||||
|
|
||||||
runImportTests (seedValue);
|
runImportTests (seedValue);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user