rippled
SHAMapStoreImp.cpp
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2013 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 
21 #include <ripple/app/ledger/TransactionMaster.h>
22 #include <ripple/app/misc/NetworkOPs.h>
23 #include <ripple/app/misc/SHAMapStoreImp.h>
24 #include <ripple/beast/core/CurrentThreadName.h>
25 #include <ripple/core/ConfigSections.h>
26 #include <ripple/nodestore/impl/DatabaseRotatingImp.h>
27 
28 #include <boost/algorithm/string/predicate.hpp>
29 
30 namespace ripple {
32  std::string const& dbName)
33 {
34  std::lock_guard lock (mutex_);
35 
36  open(session_, config, dbName);
37 
38  session_ << "PRAGMA synchronous=FULL;";
39 
40  session_ <<
41  "CREATE TABLE IF NOT EXISTS DbState ("
42  " Key INTEGER PRIMARY KEY,"
43  " WritableDb TEXT,"
44  " ArchiveDb TEXT,"
45  " LastRotatedLedger INTEGER"
46  ");"
47  ;
48 
49  session_ <<
50  "CREATE TABLE IF NOT EXISTS CanDelete ("
51  " Key INTEGER PRIMARY KEY,"
52  " CanDeleteSeq INTEGER"
53  ");"
54  ;
55 
56  std::int64_t count = 0;
57  {
58  boost::optional<std::int64_t> countO;
59  session_ <<
60  "SELECT COUNT(Key) FROM DbState WHERE Key = 1;"
61  , soci::into (countO);
62  if (!countO)
63  Throw<std::runtime_error> ("Failed to fetch Key Count from DbState.");
64  count = *countO;
65  }
66 
67  if (!count)
68  {
69  session_ <<
70  "INSERT INTO DbState VALUES (1, '', '', 0);";
71  }
72 
73 
74  {
75  boost::optional<std::int64_t> countO;
76  session_ <<
77  "SELECT COUNT(Key) FROM CanDelete WHERE Key = 1;"
78  , soci::into (countO);
79  if (!countO)
80  Throw<std::runtime_error> ("Failed to fetch Key Count from CanDelete.");
81  count = *countO;
82  }
83 
84  if (!count)
85  {
86  session_ <<
87  "INSERT INTO CanDelete VALUES (1, 0);";
88  }
89 }
90 
93 {
94  LedgerIndex seq;
95  std::lock_guard lock (mutex_);
96 
97  session_ <<
98  "SELECT CanDeleteSeq FROM CanDelete WHERE Key = 1;"
99  , soci::into (seq);
100  ;
101 
102  return seq;
103 }
104 
107 {
108  std::lock_guard lock (mutex_);
109 
110  session_ <<
111  "UPDATE CanDelete SET CanDeleteSeq = :canDelete WHERE Key = 1;"
112  , soci::use (canDelete)
113  ;
114 
115  return canDelete;
116 }
117 
120 {
121  SavedState state;
122 
123  std::lock_guard lock (mutex_);
124 
125  session_ <<
126  "SELECT WritableDb, ArchiveDb, LastRotatedLedger"
127  " FROM DbState WHERE Key = 1;"
128  , soci::into (state.writableDb), soci::into (state.archiveDb)
129  , soci::into (state.lastRotated)
130  ;
131 
132  return state;
133 }
134 
135 void
137 {
138  std::lock_guard lock (mutex_);
139  session_ <<
140  "UPDATE DbState"
141  " SET WritableDb = :writableDb,"
142  " ArchiveDb = :archiveDb,"
143  " LastRotatedLedger = :lastRotated"
144  " WHERE Key = 1;"
145  , soci::use (state.writableDb)
146  , soci::use (state.archiveDb)
147  , soci::use (state.lastRotated)
148  ;
149 }
150 
151 void
153 {
154  std::lock_guard lock (mutex_);
155  session_ <<
156  "UPDATE DbState SET LastRotatedLedger = :seq"
157  " WHERE Key = 1;"
158  , soci::use (seq)
159  ;
160 }
161 
162 //------------------------------------------------------------------------------
163 
165  Application& app,
166  Stoppable& parent,
167  NodeStore::Scheduler& scheduler,
168  beast::Journal journal)
169  : SHAMapStore (parent)
170  , app_ (app)
171  , scheduler_ (scheduler)
172  , journal_ (journal)
173  , working_(true)
174  , canDelete_ (std::numeric_limits <LedgerIndex>::max())
175 {
176  Config& config {app.config()};
177  Section& section {config.section(ConfigSection::nodeDatabase())};
178  if (section.empty())
179  {
180  Throw<std::runtime_error>(
181  "Missing [" + ConfigSection::nodeDatabase() +
182  "] entry in configuration file");
183 
184  }
185 
186  // RocksDB only. Use sensible defaults if no values specified.
187  if (boost::iequals(
188  get<std::string>(section, "type"), "RocksDB"))
189  {
190  if (!section.exists("cache_mb"))
191  {
192  section.set("cache_mb", std::to_string(
193  config.getValueFor(SizedItem::hashNodeDBCache)));
194  }
195 
196  if (!section.exists("filter_bits") && (config.NODE_SIZE >= 2))
197  section.set("filter_bits", "10");
198  }
199 
200  get_if_exists(section, "delete_batch", deleteBatch_);
201  get_if_exists(section, "backOff", backOff_);
202  get_if_exists(section, "age_threshold", ageThreshold_);
203  get_if_exists(section, "online_delete", deleteInterval_);
204 
205  if (deleteInterval_)
206  {
207  get_if_exists(section, "advisory_delete", advisoryDelete_);
208 
209  auto const minInterval = config.standalone() ?
211  if (deleteInterval_ < minInterval)
212  {
213  Throw<std::runtime_error>("online_delete must be at least " +
214  std::to_string (minInterval));
215  }
216 
217  if (config.LEDGER_HISTORY > deleteInterval_)
218  {
219  Throw<std::runtime_error>(
220  "online_delete must not be less than ledger_history (currently " +
221  std::to_string (config.LEDGER_HISTORY) + ")");
222  }
223 
224  state_db_.init(config, dbName_);
225  dbPaths();
226  }
227 }
228 
231 {
232  // Anything which calls addJob must be a descendant of the JobQueue.
233  // Therefore Database objects use the JobQueue as Stoppable parent.
235  if (deleteInterval_)
236  {
237  SavedState state = state_db_.getState();
238  auto writableBackend = makeBackendRotating(state.writableDb);
239  auto archiveBackend = makeBackendRotating(state.archiveDb);
240  if (! state.writableDb.size())
241  {
242  state.writableDb = writableBackend->getName();
243  state.archiveDb = archiveBackend->getName();
244  state_db_.setState (state);
245  }
246 
247  // Create NodeStore with two backends to allow online deletion of data
248  auto dbr = std::make_unique<NodeStore::DatabaseRotatingImp>(
249  name,
250  scheduler_,
251  readThreads,
252  app_.getJobQueue(),
253  std::move(writableBackend),
254  std::move(archiveBackend),
257  fdRequired_ += dbr->fdRequired();
258  dbRotating_ = dbr.get();
259  db.reset(dynamic_cast<NodeStore::Database*>(dbr.release()));
260  }
261  else
262  {
264  name,
265  scheduler_,
266  readThreads,
267  app_.getJobQueue(),
270  fdRequired_ += db->fdRequired();
271  }
272  return db;
273 }
274 
275 void
277  std::shared_ptr<Ledger const> const& ledger)
278 {
279  {
280  std::lock_guard lock (mutex_);
281  newLedger_ = ledger;
282  working_ = true;
283  }
284  cond_.notify_one();
285 }
286 
287 void
289 {
290  if (!working_)
291  return;
292 
294  rendezvous_.wait(lock, [&]
295  {
296  return !working_;
297  });
298 }
299 
300 int
302 {
303  return fdRequired_;
304 }
305 
306 bool
308  SHAMapAbstractNode const& node)
309 {
310  // Copy a single record from node to dbRotating_
311  dbRotating_->fetch(node.getNodeHash().as_uint256(), node.getSeq());
312  if (! (++nodeCount % checkHealthInterval_))
313  {
314  if (health())
315  return false;
316  }
317 
318  return true;
319 }
320 
321 void
323 {
324  beast::setCurrentThreadName ("SHAMapStore");
326  netOPs_ = &app_.getOPs();
332 
333  if (advisoryDelete_)
335 
336  while (true)
337  {
338  healthy_ = true;
339  std::shared_ptr<Ledger const> validatedLedger;
340 
341  {
343  working_ = false;
345  if (stop_)
346  {
347  stopped();
348  return;
349  }
350  cond_.wait (lock);
351  if (newLedger_)
352  {
353  validatedLedger = std::move(newLedger_);
354  }
355  else
356  continue;
357  }
358 
359  LedgerIndex const validatedSeq = validatedLedger->info().seq;
360  if (!lastRotated_)
361  {
362  lastRotated_ = validatedSeq;
364  }
365 
366  // will delete up to (not including) lastRotated_
367  if (validatedSeq >= lastRotated_ + deleteInterval_
368  && canDelete_ >= lastRotated_ - 1)
369  {
370  JLOG(journal_.warn()) << "rotating validatedSeq " << validatedSeq
371  << " lastRotated_ " << lastRotated_ << " deleteInterval "
372  << deleteInterval_ << " canDelete_ " << canDelete_;
373 
374  switch (health())
375  {
376  case Health::stopping:
377  stopped();
378  return;
379  case Health::unhealthy:
380  continue;
381  case Health::ok:
382  default:
383  ;
384  }
385 
387  switch (health())
388  {
389  case Health::stopping:
390  stopped();
391  return;
392  case Health::unhealthy:
393  continue;
394  case Health::ok:
395  default:
396  ;
397  }
398 
399  std::uint64_t nodeCount = 0;
400  validatedLedger->stateMap().snapShot (
401  false)->visitNodes (
403  std::ref(nodeCount), std::placeholders::_1));
404  JLOG(journal_.debug()) << "copied ledger " << validatedSeq
405  << " nodecount " << nodeCount;
406  switch (health())
407  {
408  case Health::stopping:
409  stopped();
410  return;
411  case Health::unhealthy:
412  continue;
413  case Health::ok:
414  default:
415  ;
416  }
417 
418  freshenCaches();
419  JLOG(journal_.debug()) << validatedSeq << " freshened caches";
420  switch (health())
421  {
422  case Health::stopping:
423  stopped();
424  return;
425  case Health::unhealthy:
426  continue;
427  case Health::ok:
428  default:
429  ;
430  }
431 
432  auto newBackend = makeBackendRotating();
433  JLOG(journal_.debug()) << validatedSeq << " new backend "
434  << newBackend->getName();
435 
436  clearCaches (validatedSeq);
437  switch (health())
438  {
439  case Health::stopping:
440  stopped();
441  return;
442  case Health::unhealthy:
443  continue;
444  case Health::ok:
445  default:
446  ;
447  }
448 
449  std::string nextArchiveDir =
450  dbRotating_->getWritableBackend()->getName();
451  lastRotated_ = validatedSeq;
453  {
455 
456  state_db_.setState (SavedState {newBackend->getName(),
457  nextArchiveDir, lastRotated_});
458  clearCaches (validatedSeq);
459  oldBackend = dbRotating_->rotateBackends(
460  std::move(newBackend),
461  lock);
462  }
463  JLOG(journal_.warn()) << "finished rotation " << validatedSeq;
464 
465  oldBackend->setDeletePath();
466  }
467  }
468 }
469 
470 void
472 {
474  boost::filesystem::path dbPath = get<std::string>(section, "path");
475 
476  if (boost::filesystem::exists (dbPath))
477  {
478  if (! boost::filesystem::is_directory (dbPath))
479  {
480  journal_.error() << "node db path must be a directory. "
481  << dbPath.string();
482  Throw<std::runtime_error> (
483  "node db path must be a directory.");
484  }
485  }
486  else
487  {
488  boost::filesystem::create_directories (dbPath);
489  }
490 
491  SavedState state = state_db_.getState();
492 
493  {
494  auto update = [&dbPath](std::string& sPath)
495  {
496  if (sPath.empty())
497  return false;
498 
499  // Check if configured "path" matches stored directory path
500  using namespace boost::filesystem;
501  auto const stored {path(sPath)};
502  if (stored.parent_path() == dbPath)
503  return false;
504 
505  sPath = (dbPath / stored.filename()).string();
506  return true;
507  };
508 
509  if (update(state.writableDb))
510  {
511  update(state.archiveDb);
512  state_db_.setState(state);
513  }
514  }
515 
516  bool writableDbExists = false;
517  bool archiveDbExists = false;
518 
519  for (boost::filesystem::directory_iterator it (dbPath);
520  it != boost::filesystem::directory_iterator(); ++it)
521  {
522  if (! state.writableDb.compare (it->path().string()))
523  writableDbExists = true;
524  else if (! state.archiveDb.compare (it->path().string()))
525  archiveDbExists = true;
526  else if (! dbPrefix_.compare (it->path().stem().string()))
527  boost::filesystem::remove_all (it->path());
528  }
529 
530  if ((!writableDbExists && state.writableDb.size()) ||
531  (!archiveDbExists && state.archiveDb.size()) ||
532  (writableDbExists != archiveDbExists) ||
533  state.writableDb.empty() != state.archiveDb.empty())
534  {
535  boost::filesystem::path stateDbPathName =
536  app_.config().legacy("database_path");
537  stateDbPathName /= dbName_;
538  stateDbPathName += "*";
539 
540  journal_.error() << "state db error:\n"
541  << " writableDbExists " << writableDbExists
542  << " archiveDbExists " << archiveDbExists << '\n'
543  << " writableDb '" << state.writableDb
544  << "' archiveDb '" << state.archiveDb << "\n\n"
545  << "The existing data is in a corrupted state.\n"
546  << "To resume operation, remove the files matching "
547  << stateDbPathName.string()
548  << " and contents of the directory "
549  << get<std::string>(section, "path") << '\n'
550  << "Optionally, you can move those files to another\n"
551  << "location if you wish to analyze or back up the data.\n"
552  << "However, there is no guarantee that the data in its\n"
553  << "existing form is usable.";
554 
555  Throw<std::runtime_error> ("state db error");
556  }
557 }
558 
561 {
563  boost::filesystem::path newPath;
564 
565  if (path.size())
566  {
567  newPath = path;
568  }
569  else
570  {
571  boost::filesystem::path p = get<std::string>(section, "path");
572  p /= dbPrefix_;
573  p += ".%%%%";
574  newPath = boost::filesystem::unique_path (p);
575  }
576  section.set("path", newPath.string());
577 
579  section, scheduler_, app_.logs().journal(nodeStoreName_))};
580  backend->open();
581  return backend;
582 }
583 
584 bool
586  LedgerIndex lastRotated,
587  std::string const& minQuery,
588  std::string const& deleteQuery)
589 {
591 
592  {
593  auto db = database.checkoutDb ();
594  boost::optional<std::uint64_t> m;
595  *db << minQuery, soci::into(m);
596  if (!m)
597  return false;
598  min = *m;
599  }
600 
601  if(min > lastRotated || health() != Health::ok)
602  return false;
603 
604  boost::format formattedDeleteQuery (deleteQuery);
605 
606  JLOG(journal_.debug()) <<
607  "start: " << deleteQuery << " from " << min << " to " << lastRotated;
608  while (min < lastRotated)
609  {
610  min = std::min(lastRotated, min + deleteBatch_);
611  {
612  auto db = database.checkoutDb ();
613  *db << boost::str (formattedDeleteQuery % min);
614  }
615  if (health())
616  return true;
617  if (min < lastRotated)
620  }
621  JLOG(journal_.debug()) << "finished: " << deleteQuery;
622  return true;
623 }
624 
625 void
627 {
628  ledgerMaster_->clearLedgerCachePrior (validatedSeq);
630 }
631 
632 void
634 {
636  return;
638  return;
640  return;
641 }
642 
643 void
645 {
646  if (health())
647  return;
648 
649  ledgerMaster_->clearPriorLedgers (lastRotated);
650  if (health())
651  return;
652 
653  clearSql (*ledgerDb_, lastRotated,
654  "SELECT MIN(LedgerSeq) FROM Ledgers;",
655  "DELETE FROM Ledgers WHERE LedgerSeq < %u;");
656  if (health())
657  return;
658 
659  clearSql (*transactionDb_, lastRotated,
660  "SELECT MIN(LedgerSeq) FROM Transactions;",
661  "DELETE FROM Transactions WHERE LedgerSeq < %u;");
662  if (health())
663  return;
664 
665  clearSql (*transactionDb_, lastRotated,
666  "SELECT MIN(LedgerSeq) FROM AccountTransactions;",
667  "DELETE FROM AccountTransactions WHERE LedgerSeq < %u;");
668  if (health())
669  return;
670 }
671 
674 {
675  {
676  std::lock_guard lock (mutex_);
677  if (stop_)
678  return Health::stopping;
679  }
680  if (! netOPs_)
681  return Health::ok;
682 
683  constexpr static std::chrono::seconds age_threshold(60);
684  auto age = ledgerMaster_->getValidatedLedgerAge();
686  if (mode != OperatingMode::FULL || age > age_threshold)
687  {
688  JLOG(journal_.warn()) << "Not deleting. state: "
689  << app_.getOPs().strOperatingMode(mode, false)
690  << ". age " << age.count() << 's';
691  healthy_ = false;
692  }
693 
694  if (healthy_)
695  return Health::ok;
696  else
697  return Health::unhealthy;
698 }
699 
700 void
702 {
703  if (deleteInterval_)
704  {
705  {
706  std::lock_guard lock (mutex_);
707  stop_ = true;
708  }
709  cond_.notify_one();
710  }
711  else
712  {
713  stopped();
714  }
715 }
716 
717 void
719 {
720  if (deleteInterval_)
721  {
722  {
723  std::lock_guard lock (mutex_);
724  stop_ = true;
725  }
726  cond_.notify_one();
727  }
728  else
729  {
730  stopped();
731  }
732 }
733 
734 //------------------------------------------------------------------------------
735 
738  Application& app,
739  Stoppable& parent,
740  NodeStore::Scheduler& scheduler,
741  beast::Journal journal)
742 {
743  return std::make_unique<SHAMapStoreImp>(app, parent, scheduler, journal);
744 }
745 
746 }
ripple::Section
Holds a collection of configuration values.
Definition: BasicConfig.h:43
ripple::SHAMapStoreImp::SavedStateDB::setCanDelete
LedgerIndex setCanDelete(LedgerIndex canDelete)
Definition: SHAMapStoreImp.cpp:106
ripple::SHAMapStoreImp::health
Health health()
Definition: SHAMapStoreImp.cpp:673
ripple::Application
Definition: Application.h:85
ripple::SHAMapStoreImp::dbPaths
void dbPaths()
Definition: SHAMapStoreImp.cpp:471
std::this_thread::sleep_for
T sleep_for(T... args)
ripple::SHAMapStoreImp::SHAMapStoreImp
SHAMapStoreImp(Application &app, Stoppable &parent, NodeStore::Scheduler &scheduler, beast::Journal journal)
Definition: SHAMapStoreImp.cpp:164
ripple::SHAMapStoreImp::healthy_
bool healthy_
Definition: SHAMapStoreImp.h:102
std::bind
T bind(T... args)
ripple::SHAMapStoreImp::scheduler_
NodeStore::Scheduler & scheduler_
Definition: SHAMapStoreImp.h:96
ripple::NodeStore::Database
Persistency layer for NodeObject.
Definition: Database.h:53
ripple::LedgerMaster::clearLedgerCachePrior
void clearLedgerCachePrior(LedgerIndex seq)
Definition: LedgerMaster.cpp:1736
std::string
STL class.
ripple::SHAMapStoreImp::ledgerDb_
DatabaseCon * ledgerDb_
Definition: SHAMapStoreImp.h:124
std::shared_ptr
STL class.
ripple::Stoppable::stopped
void stopped()
Called by derived classes to indicate that the stoppable has stopped.
Definition: Stoppable.cpp:71
ripple::SHAMapStoreImp::newLedger_
std::shared_ptr< Ledger const > newLedger_
Definition: SHAMapStoreImp.h:106
ripple::SHAMapStoreImp::onLedgerClosed
void onLedgerClosed(std::shared_ptr< Ledger const > const &ledger) override
Called by LedgerMaster every time a ledger validates.
Definition: SHAMapStoreImp.cpp:276
ripple::SHAMapStoreImp::minimumDeletionInterval_
static const std::uint32_t minimumDeletionInterval_
Definition: SHAMapStoreImp.h:85
ripple::SHAMapStoreImp::dbPrefix_
const std::string dbPrefix_
Definition: SHAMapStoreImp.h:81
ripple::SHAMapStoreImp::ledgerMaster_
LedgerMaster * ledgerMaster_
Definition: SHAMapStoreImp.h:120
ripple::SHAMapStoreImp::mutex_
std::mutex mutex_
Definition: SHAMapStoreImp.h:105
std::string::size
T size(T... args)
std::chrono::milliseconds
ripple::SHAMapStore
class to create database, launch online delete thread, and related SQLite database
Definition: SHAMapStore.h:36
ripple::SHAMapStoreImp::transactionDb_
DatabaseCon * transactionDb_
Definition: SHAMapStoreImp.h:123
beast::Journal::warn
Stream warn() const
Definition: Journal.h:302
std::lock_guard
STL class.
ripple::NetworkOPs::getOperatingMode
virtual OperatingMode getOperatingMode() const =0
ripple::SHAMapStoreImp::journal_
const beast::Journal journal_
Definition: SHAMapStoreImp.h:97
ripple::SHAMapStoreImp::cond_
std::condition_variable cond_
Definition: SHAMapStoreImp.h:103
ripple::SHAMapStoreImp::freshenCaches
void freshenCaches()
Definition: SHAMapStoreImp.cpp:633
ripple::SizedItem::hashNodeDBCache
@ hashNodeDBCache
ripple::SHAMapStoreImp::SavedStateDB::getCanDelete
LedgerIndex getCanDelete()
Definition: SHAMapStoreImp.cpp:92
ripple::SHAMapStoreImp::SavedStateDB::mutex_
std::mutex mutex_
Definition: SHAMapStoreImp.h:57
ripple::NodeStore::Manager::make_Backend
virtual std::unique_ptr< Backend > make_Backend(Section const &parameters, Scheduler &scheduler, beast::Journal journal)=0
Create a backend.
ripple::SHAMapStoreImp::nodeStoreName_
static constexpr auto nodeStoreName_
Definition: SHAMapStoreImp.h:126
ripple::SHAMapStoreImp::ageThreshold_
std::int32_t ageThreshold_
Definition: SHAMapStoreImp.h:115
ripple::SHAMapStoreImp::run
void run()
Definition: SHAMapStoreImp.cpp:322
std::unique_ptr::reset
T reset(T... args)
ripple::Application::getOPs
virtual NetworkOPs & getOPs()=0
ripple::SHAMapStoreImp::dbRotating_
NodeStore::DatabaseRotating * dbRotating_
Definition: SHAMapStoreImp.h:98
ripple::NodeStore::DatabaseRotating::rotateBackends
virtual std::shared_ptr< Backend > rotateBackends(std::shared_ptr< Backend > newBackend, std::lock_guard< std::mutex > const &)=0
ripple::get_if_exists
bool get_if_exists(Section const &section, std::string const &name, T &v)
Definition: BasicConfig.h:342
ripple::SHAMapStoreImp::app_
Application & app_
Definition: SHAMapStoreImp.h:76
ripple::Stoppable
Provides an interface for starting and stopping.
Definition: Stoppable.h:200
ripple::SHAMapStoreImp::stop_
bool stop_
Definition: SHAMapStoreImp.h:101
ripple::DatabaseCon::checkoutDb
LockedSociSession checkoutDb()
Definition: DatabaseCon.h:123
ripple::Application::family
virtual Family & family()=0
ripple::Application::getLedgerMaster
virtual LedgerMaster & getLedgerMaster()=0
ripple::Config
Definition: Config.h:67
ripple::SHAMapStoreImp::SavedStateDB::session_
soci::session session_
Definition: SHAMapStoreImp.h:56
ripple::SHAMapStoreImp::advisoryDelete_
bool advisoryDelete_
Definition: SHAMapStoreImp.h:112
ripple::SHAMapAbstractNode::getNodeHash
SHAMapHash const & getNodeHash() const
Definition: SHAMapTreeNode.h:251
ripple::SHAMapAbstractNode::getSeq
std::uint32_t getSeq() const
Definition: SHAMapTreeNode.h:237
ripple::NodeStore::Database::fetch
virtual std::shared_ptr< NodeObject > fetch(uint256 const &hash, std::uint32_t seq)=0
Fetch an object.
ripple::Application::config
virtual Config & config()=0
std::unique_lock
STL class.
std::string::compare
T compare(T... args)
ripple::SHAMapStoreImp::SavedStateDB::setState
void setState(SavedState const &state)
Definition: SHAMapStoreImp.cpp:136
ripple::SHAMapStoreImp::treeNodeCache_
TreeNodeCache * treeNodeCache_
Definition: SHAMapStoreImp.h:122
ripple::SHAMapStoreImp::working_
std::atomic< bool > working_
Definition: SHAMapStoreImp.h:107
std::to_string
T to_string(T... args)
ripple::SHAMapStoreImp::deleteInterval_
std::uint32_t deleteInterval_
Definition: SHAMapStoreImp.h:111
ripple::Application::getJobQueue
virtual JobQueue & getJobQueue()=0
ripple::SHAMapStoreImp::onStop
void onStop() override
Override called when the stop notification is issued.
Definition: SHAMapStoreImp.cpp:701
ripple::NodeStore::DatabaseRotating::getWritableBackend
virtual std::shared_ptr< Backend > const & getWritableBackend() const =0
beast::Journal::error
Stream error() const
Definition: Journal.h:307
ripple::BasicConfig::legacy
void legacy(std::string const &section, std::string value)
Set a value that is not a key/value pair.
Definition: BasicConfig.cpp:173
ripple::Application::logs
virtual Logs & logs()=0
ripple::SHAMapStoreImp::copyNode
bool copyNode(std::uint64_t &nodeCount, SHAMapAbstractNode const &node)
Definition: SHAMapStoreImp.cpp:307
ripple::SHAMapStoreImp::SavedState::writableDb
std::string writableDb
Definition: SHAMapStoreImp.h:41
ripple::TransactionMaster::getCache
TaggedCache< uint256, Transaction > & getCache()
Definition: TransactionMaster.cpp:140
ripple::SHAMapStoreImp::clearPrior
void clearPrior(LedgerIndex lastRotated)
Definition: SHAMapStoreImp.cpp:644
ripple::SHAMapStoreImp::SavedStateDB::getState
SavedState getState()
Definition: SHAMapStoreImp.cpp:119
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:60
ripple::Application::getLedgerDB
virtual DatabaseCon & getLedgerDB()=0
std::int64_t
std::condition_variable::wait
T wait(T... args)
ripple::SHAMapStoreImp::backOff_
std::uint32_t backOff_
Definition: SHAMapStoreImp.h:114
ripple::SHAMapStoreImp::SavedState
Definition: SHAMapStoreImp.h:39
ripple::NodeStore::Scheduler
Scheduling for asynchronous backend activity.
Definition: ripple/nodestore/Scheduler.h:57
ripple::SHAMapStoreImp::Health
Health
Definition: SHAMapStoreImp.h:46
ripple::SHAMapStoreImp::checkHealthInterval_
const std::uint64_t checkHealthInterval_
Definition: SHAMapStoreImp.h:83
ripple::Family::treecache
virtual TreeNodeCache & treecache()=0
ripple::SHAMapStoreImp::state_db_
SavedStateDB state_db_
Definition: SHAMapStoreImp.h:99
ripple::SHAMapStoreImp::lastRotated_
std::atomic< LedgerIndex > lastRotated_
Definition: SHAMapStoreImp.h:94
std::min
T min(T... args)
std::condition_variable::notify_one
T notify_one(T... args)
ripple::SHAMapStoreImp::SavedState::archiveDb
std::string archiveDb
Definition: SHAMapStoreImp.h:42
ripple::SHAMapStoreImp::SavedStateDB::init
void init(BasicConfig const &config, std::string const &dbName)
Definition: SHAMapStoreImp.cpp:31
ripple::LedgerMaster::getValidatedLedgerAge
std::chrono::seconds getValidatedLedgerAge()
Definition: LedgerMaster.cpp:276
ripple::SHAMapStoreImp::dbName_
const std::string dbName_
Definition: SHAMapStoreImp.h:79
beast::setCurrentThreadName
void setCurrentThreadName(std::string_view name)
Changes the name of the caller thread.
Definition: CurrentThreadName.cpp:113
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::SHAMapStoreImp::SavedState::lastRotated
LedgerIndex lastRotated
Definition: SHAMapStoreImp.h:43
ripple::SHAMapStoreImp::fdRequired
int fdRequired() const override
Returns the number of file descriptors that are needed.
Definition: SHAMapStoreImp.cpp:301
ripple::Logs::journal
beast::Journal journal(std::string const &name)
Definition: Log.cpp:140
ripple::make_SHAMapStore
std::unique_ptr< SHAMapStore > make_SHAMapStore(Application &app, Stoppable &parent, NodeStore::Scheduler &scheduler, beast::Journal journal)
Definition: SHAMapStoreImp.cpp:737
std
STL namespace.
ripple::SHAMapStoreImp::SavedStateDB::setLastRotated
void setLastRotated(LedgerIndex seq)
Definition: SHAMapStoreImp.cpp:152
ripple::SHAMapStoreImp::canDelete_
std::atomic< LedgerIndex > canDelete_
Definition: SHAMapStoreImp.h:108
ripple::SHAMapStoreImp::minimumDeletionIntervalSA_
static const std::uint32_t minimumDeletionIntervalSA_
Definition: SHAMapStoreImp.h:87
ripple::DatabaseCon
Definition: DatabaseCon.h:77
ripple::NodeStore::DatabaseRotating::getPositiveCache
virtual TaggedCache< uint256, NodeObject > const & getPositiveCache()=0
ripple::SHAMapStoreImp::onChildrenStopped
void onChildrenStopped() override
Override called when all children have stopped.
Definition: SHAMapStoreImp.cpp:718
ripple::SHAMapStoreImp::deleteBatch_
std::uint32_t deleteBatch_
Definition: SHAMapStoreImp.h:113
ripple::SHAMapStoreImp::fullBelowCache_
FullBelowCache * fullBelowCache_
Definition: SHAMapStoreImp.h:121
ripple::SHAMapStoreImp::clearCaches
void clearCaches(LedgerIndex validatedSeq)
Definition: SHAMapStoreImp.cpp:626
ripple::SHAMapAbstractNode
Definition: SHAMapTreeNode.h:92
std::string::empty
T empty(T... args)
ripple::NetworkOPs::strOperatingMode
virtual std::string strOperatingMode(OperatingMode const mode, bool const admin=false) const =0
ripple::OperatingMode
OperatingMode
Specifies the mode under which the server believes it's operating.
Definition: NetworkOPs.h:68
ripple::SHAMapStoreImp::makeBackendRotating
std::unique_ptr< NodeStore::Backend > makeBackendRotating(std::string path=std::string())
Definition: SHAMapStoreImp.cpp:560
beast::Journal::debug
Stream debug() const
Definition: Journal.h:292
ripple::Family::fullbelow
virtual FullBelowCache & fullbelow()=0
ripple::SHAMapStoreImp::makeNodeStore
std::unique_ptr< NodeStore::Database > makeNodeStore(std::string const &name, std::int32_t readThreads) override
Definition: SHAMapStoreImp.cpp:230
ripple::SHAMapHash::as_uint256
uint256 const & as_uint256() const
Definition: SHAMapTreeNode.h:53
ripple::NodeStore::Manager::make_Database
virtual std::unique_ptr< Database > make_Database(std::string const &name, Scheduler &scheduler, int readThreads, Stoppable &parent, Section const &backendParameters, beast::Journal journal)=0
Construct a NodeStore database.
ripple::NodeStore::Manager::instance
static Manager & instance()
Returns the instance of the manager singleton.
Definition: ManagerImp.cpp:117
ripple::SHAMapStoreImp::fdRequired_
int fdRequired_
Definition: SHAMapStoreImp.h:109
ripple::SHAMapStoreImp::netOPs_
NetworkOPs * netOPs_
Definition: SHAMapStoreImp.h:119
std::unique_ptr
STL class.
ripple::SHAMapStoreImp::freshenCache
bool freshenCache(CacheInstance &cache)
Definition: SHAMapStoreImp.h:197
std::numeric_limits
ripple::LedgerMaster::clearPriorLedgers
void clearPriorLedgers(LedgerIndex seq)
Definition: LedgerMaster.cpp:1728
ripple::NodeStore::DatabaseRotating::peekMutex
virtual std::mutex & peekMutex() const =0
std::condition_variable::notify_all
T notify_all(T... args)
ripple::BasicConfig
Holds unparsed configuration information.
Definition: BasicConfig.h:177
ripple::detail::BasicFullBelowCache::clear
void clear()
Definition: FullBelowCache.h:123
ripple::ConfigSection::nodeDatabase
static std::string nodeDatabase()
Definition: ConfigSections.h:32
std::ref
T ref(T... args)
ripple::SHAMapStoreImp::rendezvous
void rendezvous() const override
Definition: SHAMapStoreImp.cpp:288
ripple::SHAMapStoreImp::clearSql
bool clearSql(DatabaseCon &database, LedgerIndex lastRotated, std::string const &minQuery, std::string const &deleteQuery)
delete from sqlite table in batches to not lock the db excessively pause briefly to extend access tim...
Definition: SHAMapStoreImp.cpp:585
ripple::Application::getTxnDB
virtual DatabaseCon & getTxnDB()=0
ripple::open
void open(soci::session &s, BasicConfig const &config, std::string const &dbName)
Open a soci session.
Definition: SociDB.cpp:98
ripple::BasicConfig::section
Section & section(std::string const &name)
Returns the section with the given name.
Definition: BasicConfig.cpp:140
ripple::SHAMapStoreImp::rendezvous_
std::condition_variable rendezvous_
Definition: SHAMapStoreImp.h:104
ripple::Application::getMasterTransaction
virtual TransactionMaster & getMasterTransaction()=0
ripple::OperatingMode::FULL
@ FULL
we have the ledger and can even validate