mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Prevent low-likelihood crash on shutdown (RIPD-1392):
The DatabaseImp has threads that asynchronously call JobQueue to perform database reads. Formerly these threads had the same lifespan as Database, which was until the end-of-life of ApplicationImp. During shutdown these threads could call JobQueue after JobQueue had already stopped. Or, even worse, occasionally call JobQueue after JobQueue's destructor had run. To avoid these shutdown conditions, Database is made a Stoppable, with JobQueue as its parent. When Database stops, it shuts down its asynchronous read threads. This prevents Database from accessing JobQueue after JobQueue has stopped, but allows Database to perform stores for the remainder of shutdown. During development it was noted that the Database::close() method was never called. So that method is removed from Database and all derived classes. Stoppable is also adjusted so it can be constructed using either a char const* or a std::string. For those files touched for other reasons, unneeded #includes are removed.
This commit is contained in:
@@ -23,7 +23,6 @@
|
||||
#include <ripple/app/main/DBInit.h>
|
||||
#include <ripple/app/main/BasicApp.h>
|
||||
#include <ripple/app/main/Tuning.h>
|
||||
#include <ripple/app/ledger/AcceptedLedger.h>
|
||||
#include <ripple/app/ledger/InboundLedgers.h>
|
||||
#include <ripple/app/ledger/LedgerMaster.h>
|
||||
#include <ripple/app/ledger/LedgerToJson.h>
|
||||
@@ -32,59 +31,29 @@
|
||||
#include <ripple/app/ledger/PendingSaves.h>
|
||||
#include <ripple/app/ledger/InboundTransactions.h>
|
||||
#include <ripple/app/ledger/TransactionMaster.h>
|
||||
#include <ripple/app/main/CollectorManager.h>
|
||||
#include <ripple/app/main/LoadManager.h>
|
||||
#include <ripple/app/main/NodeIdentity.h>
|
||||
#include <ripple/app/main/NodeStoreScheduler.h>
|
||||
#include <ripple/app/misc/AmendmentTable.h>
|
||||
#include <ripple/app/misc/HashRouter.h>
|
||||
#include <ripple/app/misc/LoadFeeTrack.h>
|
||||
#include <ripple/app/misc/Manifest.h>
|
||||
#include <ripple/app/misc/NetworkOPs.h>
|
||||
#include <ripple/app/misc/SHAMapStore.h>
|
||||
#include <ripple/app/misc/TxQ.h>
|
||||
#include <ripple/app/misc/Validations.h>
|
||||
#include <ripple/app/misc/ValidatorList.h>
|
||||
#include <ripple/app/misc/ValidatorSite.h>
|
||||
#include <ripple/app/paths/Pathfinder.h>
|
||||
#include <ripple/app/paths/PathRequests.h>
|
||||
#include <ripple/app/tx/apply.h>
|
||||
#include <ripple/basics/contract.h>
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/basics/ResolverAsio.h>
|
||||
#include <ripple/basics/Sustain.h>
|
||||
#include <ripple/basics/chrono.h>
|
||||
#include <ripple/json/json_reader.h>
|
||||
#include <ripple/json/to_string.h>
|
||||
#include <ripple/core/ConfigSections.h>
|
||||
#include <ripple/core/DeadlineTimer.h>
|
||||
#include <ripple/core/TimeKeeper.h>
|
||||
#include <ripple/ledger/CachedSLEs.h>
|
||||
#include <ripple/nodestore/Database.h>
|
||||
#include <ripple/nodestore/DummyScheduler.h>
|
||||
#include <ripple/nodestore/Manager.h>
|
||||
#include <ripple/overlay/Cluster.h>
|
||||
#include <ripple/overlay/make_Overlay.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/PublicKey.h>
|
||||
#include <ripple/protocol/SecretKey.h>
|
||||
#include <ripple/protocol/STParsedJSON.h>
|
||||
#include <ripple/protocol/types.h>
|
||||
#include <ripple/resource/Charge.h>
|
||||
#include <ripple/resource/Consumer.h>
|
||||
#include <ripple/resource/Fees.h>
|
||||
#include <ripple/rpc/Context.h>
|
||||
#include <ripple/rpc/RPCHandler.h>
|
||||
#include <ripple/shamap/Family.h>
|
||||
#include <ripple/crypto/csprng.h>
|
||||
#include <ripple/beast/asio/io_latency_probe.h>
|
||||
#include <ripple/beast/core/LexicalCast.h>
|
||||
#include <beast/core/detail/ci_char_traits.hpp>
|
||||
#include <boost/asio/signal_set.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -325,7 +294,6 @@ public:
|
||||
|
||||
NodeStoreScheduler m_nodeStoreScheduler;
|
||||
std::unique_ptr <SHAMapStore> m_shaMapStore;
|
||||
std::unique_ptr <NodeStore::Database> m_nodeStore;
|
||||
PendingSaves pendingSaves_;
|
||||
AccountIDCache accountIDCache_;
|
||||
boost::optional<OpenLedger> openLedger_;
|
||||
@@ -333,7 +301,6 @@ public:
|
||||
// These are not Stoppable-derived
|
||||
NodeCache m_tempNodeCache;
|
||||
std::unique_ptr <CollectorManager> m_collectorManager;
|
||||
detail::AppFamily family_;
|
||||
CachedSLEs cachedSLEs_;
|
||||
std::pair<PublicKey, SecretKey> nodeIdentity_;
|
||||
|
||||
@@ -341,6 +308,8 @@ public:
|
||||
|
||||
// These are Stoppable-related
|
||||
std::unique_ptr <JobQueue> m_jobQueue;
|
||||
std::unique_ptr <NodeStore::Database> m_nodeStore;
|
||||
detail::AppFamily family_;
|
||||
// VFALCO TODO Make OrderBookDB abstract
|
||||
OrderBookDB m_orderBookDB;
|
||||
std::unique_ptr <PathRequests> m_pathRequests;
|
||||
@@ -416,8 +385,6 @@ public:
|
||||
logs_->journal ("SHAMapStore"), logs_->journal ("NodeObject"),
|
||||
m_txMaster, *config_))
|
||||
|
||||
, m_nodeStore (m_shaMapStore->makeDatabase ("NodeStore.main", 4))
|
||||
|
||||
, accountIDCache_(128000)
|
||||
|
||||
, m_tempNodeCache ("NodeCache", 16384, 90, stopwatch(),
|
||||
@@ -426,8 +393,6 @@ public:
|
||||
, m_collectorManager (CollectorManager::New (
|
||||
config_->section (SECTION_INSIGHT), logs_->journal("Collector")))
|
||||
|
||||
, family_ (*this, *m_nodeStore, *m_collectorManager)
|
||||
|
||||
, cachedSLEs_ (std::chrono::minutes(1), stopwatch())
|
||||
|
||||
, m_resourceManager (Resource::make_Manager (
|
||||
@@ -443,6 +408,10 @@ public:
|
||||
//
|
||||
// Anything which calls addJob must be a descendant of the JobQueue
|
||||
//
|
||||
, m_nodeStore (
|
||||
m_shaMapStore->makeDatabase ("NodeStore.main", 4, *m_jobQueue))
|
||||
|
||||
, family_ (*this, *m_nodeStore, *m_collectorManager)
|
||||
|
||||
, m_orderBookDB (*this, *m_jobQueue)
|
||||
|
||||
@@ -1964,9 +1933,9 @@ bool ApplicationImp::updateTables ()
|
||||
auto j = logs_->journal("NodeObject");
|
||||
NodeStore::DummyScheduler scheduler;
|
||||
std::unique_ptr <NodeStore::Database> source =
|
||||
NodeStore::Manager::instance().make_Database ("NodeStore.import", scheduler,
|
||||
j, 0,
|
||||
config_->section(ConfigSection::importNodeDatabase ()));
|
||||
NodeStore::Manager::instance().make_Database ("NodeStore.import",
|
||||
scheduler, 0, *m_jobQueue,
|
||||
config_->section(ConfigSection::importNodeDatabase ()), j);
|
||||
|
||||
JLOG (j.warn())
|
||||
<< "Node import from '" << source->getName () << "' to '"
|
||||
|
||||
Reference in New Issue
Block a user