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