Skip to content

Commit

Permalink
[FOLD] Travis debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
undertome committed Nov 3, 2021
1 parent 122b851 commit 40f18f1
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/ripple/app/main/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -875,14 +875,18 @@ class ApplicationImp : public Application, public BasicApp

try
{
std::cout << "initRDBMS - a" << std::endl;
mRelationalDatabase =
RelationalDatabase::init(*this, *config_, *m_jobQueue);

std::cout << "initRDBMS - b" << std::endl;
// wallet database
auto setup = setup_DatabaseCon(*config_, m_journal);
setup.useGlobalPragma = false;
std::cout << "initRDBMS - a" << std::endl;

mWalletDB = makeWalletDB(setup);
std::cout << "initRDBMS - a" << std::endl;
}
catch (std::exception const& e)
{
Expand Down
4 changes: 3 additions & 1 deletion src/ripple/app/main/DBInit.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ inline constexpr std::array<char const*, 5> LgrDBInit{
// Transaction database holds transactions and public keys
inline constexpr auto TxDBName{"transaction.db"};

inline constexpr std::array TxDBPragma
inline constexpr std::array<char const*, 4> TxDBPragma
{
"PRAGMA page_size=4096;", "PRAGMA journal_size_limit=1582080;",
"PRAGMA max_page_count=2147483646;",
#if (ULONG_MAX > UINT_MAX) && !defined(NO_SQLITE_MMAP)
"PRAGMA mmap_size=17179869184;"
#else
"PRAGMA sqlite_noop_statement;"
#endif
};

Expand Down
27 changes: 27 additions & 0 deletions src/ripple/app/rdb/backend/detail/impl/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,47 @@ makeLedgerDBs(
DatabaseCon::Setup const& setup,
DatabaseCon::CheckpointerSetup const& checkpointerSetup)
{
std::cout << "detail::makeLedgerDBs 1" << std::endl;

// ledger database
auto lgr{std::make_unique<DatabaseCon>(
setup, LgrDBName, LgrDBPragma, LgrDBInit, checkpointerSetup)};
lgr->getSession() << boost::str(
boost::format("PRAGMA cache_size=-%d;") %
kilobytes(config.getValueFor(SizedItem::lgrDBCache)));

std::vector<std::string> prag;
std::transform(
LgrDBPragma.begin(),
LgrDBPragma.end(),
std::back_inserter(prag),
[](const char* c) { return std::string(c); });

std::cout << "detail::makeLedgerDBs LgrDBPragma: "
<< boost::algorithm::join(prag, ", ") << std::endl;

std::cout << "detail::makeLedgerDBs 2" << std::endl;
if (config.useTxTables())
{
prag.clear();
std::transform(
TxDBPragma.begin(),
TxDBPragma.end(),
std::back_inserter(prag),
[](const char* c) { return std::string(c); });

std::cout << "detail::makeLedgerDBs 2.1" << std::endl;
std::cout << "detail::makeLedgerDBs TxDBPragma: "
<< boost::algorithm::join(prag, ", ") << std::endl;
// transaction database
auto tx{std::make_unique<DatabaseCon>(
setup, TxDBName, TxDBPragma, TxDBInit, checkpointerSetup)};
std::cout << "detail::makeLedgerDBs 2.2" << std::endl;
tx->getSession() << boost::str(
boost::format("PRAGMA cache_size=-%d;") %
kilobytes(config.getValueFor(SizedItem::txnDBCache)));

std::cout << "detail::makeLedgerDBs 3" << std::endl;
if (!setup.standAlone || setup.startUp == Config::LOAD ||
setup.startUp == Config::LOAD_FILE ||
setup.startUp == Config::REPLAY)
Expand Down Expand Up @@ -116,7 +141,9 @@ makeLedgerDBs(
return {std::move(lgr), std::move(tx), true};
}
else
{
return {std::move(lgr), {}, true};
}
}

std::optional<LedgerIndex>
Expand Down
22 changes: 22 additions & 0 deletions src/ripple/app/rdb/backend/impl/SQLiteDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ class SQLiteDatabaseImp : public SQLiteDatabase
, useTxTables_(config.useTxTables())
, j_(app_.journal("SQLiteDatabaseImp"))
{
std::cout << "SQLiteDatabaseImp - a" << std::endl;

std::vector<std::string> prag;
std::transform(
TxDBPragma.begin(),
TxDBPragma.end(),
std::back_inserter(prag),
[](const char* c) { return std::string(c); });

std::cout << "SQLiteDatabaseImp::SQLiteDatabaseImp TxDBPragma: "
<< boost::algorithm::join(prag, ", ") << std::endl;
DatabaseCon::Setup setup = setup_DatabaseCon(config, j_);
if (!makeLedgerDBs(
config,
Expand All @@ -61,6 +72,7 @@ class SQLiteDatabaseImp : public SQLiteDatabase
JLOG(j_.fatal()) << error;
Throw<std::runtime_error>(error.data());
}
std::cout << "SQLiteDatabaseImp - b" << std::endl;

if (app.getShardStore() &&
!makeMetaDBs(
Expand All @@ -74,6 +86,7 @@ class SQLiteDatabaseImp : public SQLiteDatabase
JLOG(j_.fatal()) << error;
Throw<std::runtime_error>(error.data());
}
std::cout << "SQLiteDatabaseImp - c" << std::endl;
}

std::optional<LedgerIndex>
Expand Down Expand Up @@ -448,6 +461,15 @@ SQLiteDatabaseImp::makeLedgerDBs(
DatabaseCon::Setup const& setup,
DatabaseCon::CheckpointerSetup const& checkpointerSetup)
{
std::vector<std::string> prag;
std::transform(
TxDBPragma.begin(),
TxDBPragma.end(),
std::back_inserter(prag),
[](const char* c) { return std::string(c); });

std::cout << "SQLiteDatabaseImp::makeLedgerDBs TxDBPragma: "
<< boost::algorithm::join(prag, ", ") << std::endl;
auto [lgr, tx, res] =
detail::makeLedgerDBs(config, setup, checkpointerSetup);
txdb_ = std::move(tx);
Expand Down
6 changes: 6 additions & 0 deletions src/ripple/app/rdb/impl/RelationalDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,16 @@ RelationalDatabase::init(
bool use_sqlite = false;
bool use_postgres = false;

std::cout << "RelationalDatabase::init - a" << std::endl;

if (config.reporting())
{
std::cout << "RelationalDatabase::init - b" << std::endl;
use_postgres = true;
}
else
{
std::cout << "RelationalDatabase::init - c" << std::endl;
const Section& rdb_section{config.section(SECTION_RELATIONAL_DB)};
if (!rdb_section.empty())
{
Expand All @@ -64,6 +68,7 @@ RelationalDatabase::init(
use_sqlite = true;
}
}
std::cout << "RelationalDatabase::init - d" << std::endl;

if (use_sqlite)
{
Expand All @@ -73,6 +78,7 @@ RelationalDatabase::init(
{
return getPostgresDatabase(app, config, jobQueue);
}
std::cout << "RelationalDatabase::init - e" << std::endl;

return std::unique_ptr<RelationalDatabase>();
}
Expand Down
18 changes: 18 additions & 0 deletions src/ripple/core/DatabaseCon.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <ripple/app/main/DBInit.h>
#include <ripple/core/Config.h>
#include <ripple/core/SociDB.h>
#include <boost/algorithm/string/join.hpp>
#include <boost/filesystem/path.hpp>
#include <mutex>
#include <optional>
Expand Down Expand Up @@ -194,6 +195,22 @@ class DatabaseCon
{
open(*session_, "sqlite", pPath.string());

std::cout << "DatabaseCon --- " << std::endl
<< "path: " << pPath << " pragma size: " << N << std::endl;

#if (ULONG_MAX > UINT_MAX) && !defined(NO_SQLITE_MMAP)
std::cout << "#if is triggered" << std::endl;
#endif

std::vector<std::string> p;
std::transform(
pragma.begin(),
pragma.end(),
std::back_inserter(p),
[](const char* c) { return std::string(c); });

std::cout << "detail::DatabaseCon pragma: "
<< boost::algorithm::join(p, "\n") << std::endl;
if (commonPragma)
{
for (auto const& p : *commonPragma)
Expand All @@ -204,6 +221,7 @@ class DatabaseCon
}
for (auto const& p : pragma)
{
std::cout << "p: " << p << std::endl;
soci::statement st = session_->prepare << p;
st.execute(true);
}
Expand Down

0 comments on commit 40f18f1

Please sign in to comment.