Remove temp_db (RIPD-887)

This commit is contained in:
seelabs
2015-05-27 11:26:06 -07:00
committed by Vinnie Falco
parent e9d147f4b8
commit d7def5509d
11 changed files with 18 additions and 120 deletions

View File

@@ -661,7 +661,6 @@
# migrate the specified database into the current database given
# 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)
# [database_path] Path to the book-keeping databases.
#
@@ -671,7 +670,6 @@
# rippled.cfg file. Partial pathnames will be considered relative to
# the location of the rippled executable.
#
# The [temp_db] configuration setting is deprecated and should be avoided.
#
#
#

View File

@@ -168,7 +168,6 @@ setupConfigForUnitTests (Config& config)
config.overwrite (ConfigSection::nodeDatabase (), "type", "memory");
config.overwrite (ConfigSection::nodeDatabase (), "path", "main");
config.deprecatedClearSection (ConfigSection::tempNodeDatabase ());
config.deprecatedClearSection (ConfigSection::importNodeDatabase ());
config.legacy("database_path", "DummyForUnitTests");
}

View File

@@ -44,7 +44,6 @@ public:
bool advisoryDelete = false;
std::uint32_t ledgerHistory = 0;
Section nodeDatabase;
Section ephemeralNodeDatabase;
std::string databasePath;
std::uint32_t deleteBatch = 100;
std::uint32_t backOff = 100;

View File

@@ -227,8 +227,7 @@ SHAMapStoreImp::makeDatabase (std::string const& name,
else
{
db = NodeStore::Manager::instance().make_Database (name, scheduler_, nodeStoreJournal_,
readThreads, setup_.nodeDatabase,
setup_.ephemeralNodeDatabase);
readThreads, setup_.nodeDatabase);
}
return db;
@@ -492,14 +491,8 @@ SHAMapStoreImp::makeDatabaseRotating (std::string const& name,
std::shared_ptr <NodeStore::Backend> writableBackend,
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_,
readThreads, writableBackend, archiveBackend,
std::move (fastBackend), nodeStoreJournal_);
readThreads, writableBackend, archiveBackend, nodeStoreJournal_);
}
void
@@ -680,7 +673,6 @@ setup_SHAMapStore (Config const& c)
setup.ledgerHistory = c.LEDGER_HISTORY;
setup.nodeDatabase = c[ConfigSection::nodeDatabase ()];
setup.ephemeralNodeDatabase = c[ConfigSection::tempNodeDatabase ()];
setup.databasePath = c.legacy("database_path");
get_if_exists (sec, "delete_batch", setup.deleteBatch);

View File

@@ -28,7 +28,6 @@ namespace ripple {
struct ConfigSection
{
static std::string nodeDatabase () { return "node_db"; }
static std::string tempNodeDatabase () { return "temp_db"; }
static std::string importNodeDatabase () { return "import_db"; }
};

View File

@@ -87,8 +87,7 @@ public:
std::unique_ptr <Database>
make_Database (std::string const& name, Scheduler& scheduler,
beast::Journal journal, int readThreads,
Section const& backendParameters,
Section fastBackendParameters = Section()) = 0;
Section const& backendParameters) = 0;
virtual
std::unique_ptr <DatabaseRotating>
@@ -96,7 +95,6 @@ public:
Scheduler& scheduler, std::int32_t readThreads,
std::shared_ptr <Backend> writableBackend,
std::shared_ptr <Backend> archiveBackend,
std::unique_ptr <Backend> fastBackend,
beast::Journal journal) = 0;
};

View File

@@ -45,8 +45,6 @@ private:
Scheduler& m_scheduler;
// Persistent key/value storage.
std::unique_ptr <Backend> m_backend;
// Larger key/value storage, but not necessarily persistent.
std::unique_ptr <Backend> m_fastBackend;
protected:
// Positive cache
TaggedCache <uint256, NodeObject> m_cache;
@@ -67,12 +65,10 @@ public:
Scheduler& scheduler,
int readThreads,
std::unique_ptr <Backend> backend,
std::unique_ptr <Backend> fastBackend,
beast::Journal journal)
: m_journal (journal)
, m_scheduler (scheduler)
, m_backend (std::move (backend))
, m_fastBackend (std::move (fastBackend))
, m_cache ("NodeStore", cacheTargetSize, cacheTargetSeconds,
get_seconds_clock (), deprecatedLogs().journal("TaggedCache"))
, m_negCache ("NodeStore", get_seconds_clock (),
@@ -117,11 +113,6 @@ public:
m_backend->close();
m_backend = nullptr;
}
if (m_fastBackend)
{
m_fastBackend->close();
m_fastBackend = nullptr;
}
}
//------------------------------------------------------------------------------
@@ -204,20 +195,8 @@ public:
// Check the database(s).
bool foundInFastBackend = false;
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?
//
if (obj == nullptr)
@@ -246,23 +225,10 @@ public:
//
m_cache.canonicalize (hash, obj);
if (! foundInFastBackend)
{
// If we have a fast back end, store it there for later.
//
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";
}
// Since this was a 'hard' fetch, we will log it.
//
if (m_journal.trace) m_journal.trace <<
"HOS: " << hash << " fetch: in db";
}
return obj;
@@ -334,14 +300,6 @@ public:
m_storeSize += object->getData().size();
m_negCache.erase (hash);
if (m_fastBackend)
{
m_fastBackend->store (object);
++m_storeCount;
if (object)
m_storeSize += object->getData().size();
}
}
//------------------------------------------------------------------------------

View File

@@ -52,11 +52,9 @@ public:
int readThreads,
std::shared_ptr <Backend> writableBackend,
std::shared_ptr <Backend> archiveBackend,
std::unique_ptr <Backend> fastBackend,
beast::Journal journal)
: DatabaseImp (name, scheduler, readThreads,
std::unique_ptr <Backend>(), std::move (fastBackend),
journal)
std::unique_ptr <Backend>(), journal)
, writableBackend_ (writableBackend)
, archiveBackend_ (archiveBackend)
{}

View File

@@ -91,19 +91,13 @@ ManagerImp::make_Database (
Scheduler& scheduler,
beast::Journal journal,
int readThreads,
Section const& backendParameters,
Section fastBackendParameters)
Section const& backendParameters)
{
std::unique_ptr <Backend> backend (make_Backend (
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,
std::move (backend), std::move (fastBackend), journal);
std::move (backend), journal);
}
std::unique_ptr <DatabaseRotating>
@@ -113,12 +107,10 @@ ManagerImp::make_DatabaseRotating (
std::int32_t readThreads,
std::shared_ptr <Backend> writableBackend,
std::shared_ptr <Backend> archiveBackend,
std::unique_ptr <Backend> fastBackend,
beast::Journal journal)
{
return std::make_unique <DatabaseRotatingImp> (name, scheduler,
readThreads, writableBackend, archiveBackend,
std::move (fastBackend), journal);
readThreads, writableBackend, archiveBackend, journal);
}
Factory*

View File

@@ -67,8 +67,7 @@ public:
Scheduler& scheduler,
beast::Journal journal,
int readThreads,
Section const& backendParameters,
Section fastBackendParameters) override;
Section const& backendParameters) override;
std::unique_ptr <DatabaseRotating>
make_DatabaseRotating (
@@ -77,7 +76,6 @@ public:
std::int32_t readThreads,
std::shared_ptr <Backend> writableBackend,
std::shared_ptr <Backend> archiveBackend,
std::unique_ptr <Backend> fastBackend,
beast::Journal journal) override;
};

View File

@@ -87,7 +87,6 @@ public:
//--------------------------------------------------------------------------
void testNodeStore (std::string const& type,
bool const useEphemeralDatabase,
bool const testPersistence,
std::int64_t const seedValue,
int numObjectsToTest = 2000)
@@ -95,8 +94,6 @@ public:
DummyScheduler scheduler;
std::string s = "NodeStore backend '" + type + "'";
if (useEphemeralDatabase)
s += " (with ephemeral database)";
testcase (s);
@@ -105,14 +102,6 @@ public:
nodeParams.set ("type", type);
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
Batch batch;
createPredictableBatch (batch, numObjectsToTest, seedValue);
@@ -122,7 +111,7 @@ public:
{
// Open the database
std::unique_ptr <Database> db = Manager::instance().make_Database (
"test", scheduler, j, 2, nodeParams, tempParams);
"test", scheduler, j, 2, nodeParams);
// Write the batch
storeBatch (*db, batch);
@@ -159,37 +148,17 @@ public:
std::sort (copy.begin (), copy.end (), NodeObject::LessThan ());
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, &copy, 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
testNodeStore ("rocksdb", useEphemeralDatabase, true, seedValue);
#endif
#if RIPPLE_ENABLE_SQLITE_BACKEND_TESTS
testNodeStore ("sqlite", useEphemeralDatabase, true, seedValue);
testNodeStore ("rocksdb", true, seedValue);
#endif
}
@@ -214,11 +183,9 @@ public:
{
std::int64_t const seedValue = 50;
testNodeStore ("memory", false, false, seedValue);
testNodeStore ("memory", false, seedValue);
runBackendTests (false, seedValue);
runBackendTests (true, seedValue);
runBackendTests (seedValue);
runImportTests (seedValue);
}