rippled
Loading...
Searching...
No Matches
Vacuum.cpp
1#include <xrpl/server/Vacuum.h>
2
3#include <boost/format.hpp>
4
5#include <iostream>
6
7namespace xrpl {
8
9bool
11{
12 boost::filesystem::path dbPath = setup.dataDir / TxDBName;
13
14 uintmax_t const dbSize = file_size(dbPath);
15 XRPL_ASSERT(dbSize != static_cast<uintmax_t>(-1), "ripple:doVacuumDB : file_size succeeded");
16
17 if (auto available = space(dbPath.parent_path()).available; available < dbSize)
18 {
19 std::cerr << "The database filesystem must have at least as "
20 "much free space as the size of "
21 << dbPath.string() << ", which is " << dbSize << " bytes. Only " << available
22 << " bytes are available.\n";
23 return false;
24 }
25
26 auto txnDB = std::make_unique<DatabaseCon>(setup, TxDBName, setup.txPragma, TxDBInit, j);
27 auto& session = txnDB->getSession();
28 std::uint32_t pageSize;
29
30 // Only the most trivial databases will fit in memory on typical
31 // (recommended) hardware. Force temp files to be written to disk
32 // regardless of the config settings.
33 session << boost::format(CommonDBPragmaTemp) % "file";
34 session << "PRAGMA page_size;", soci::into(pageSize);
35
36 std::cout << "VACUUM beginning. page_size: " << pageSize << std::endl;
37
38 session << "VACUUM;";
39 XRPL_ASSERT(setup.globalPragma, "ripple:doVacuumDB : non-null global pragma");
40 for (auto const& p : *setup.globalPragma)
41 session << p;
42 session << "PRAGMA page_size;", soci::into(pageSize);
43
44 std::cout << "VACUUM finished. page_size: " << pageSize << std::endl;
45
46 return true;
47}
48
49} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:40
T endl(T... args)
T is_same_v
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
bool doVacuumDB(DatabaseCon::Setup const &setup, beast::Journal j)
doVacuumDB Creates, initialises, and performs cleanup on a database.
Definition Vacuum.cpp:10
constexpr std::array< char const *, 8 > TxDBInit
Definition DBInit.h:52
constexpr char const * CommonDBPragmaTemp
Definition DBInit.h:14
constexpr auto TxDBName
Definition DBInit.h:50
std::array< std::string, 4 > txPragma
Definition DatabaseCon.h:88
static std::unique_ptr< std::vector< std::string > const > globalPragma
Definition DatabaseCon.h:87
boost::filesystem::path dataDir
Definition DatabaseCon.h:72