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