diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp index b1cdf0e0735..e9a13a9b64b 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/ripple/app/main/Application.cpp @@ -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) { diff --git a/src/ripple/app/main/DBInit.h b/src/ripple/app/main/DBInit.h index 00cfc104df0..e604cdfb06e 100644 --- a/src/ripple/app/main/DBInit.h +++ b/src/ripple/app/main/DBInit.h @@ -72,12 +72,14 @@ inline constexpr std::array LgrDBInit{ // Transaction database holds transactions and public keys inline constexpr auto TxDBName{"transaction.db"}; -inline constexpr std::array TxDBPragma +inline constexpr std::array 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 }; diff --git a/src/ripple/app/rdb/backend/detail/impl/Node.cpp b/src/ripple/app/rdb/backend/detail/impl/Node.cpp index c51f39826a7..5d2dd1cdf72 100644 --- a/src/ripple/app/rdb/backend/detail/impl/Node.cpp +++ b/src/ripple/app/rdb/backend/detail/impl/Node.cpp @@ -69,6 +69,8 @@ makeLedgerDBs( DatabaseCon::Setup const& setup, DatabaseCon::CheckpointerSetup const& checkpointerSetup) { + std::cout << "detail::makeLedgerDBs 1" << std::endl; + // ledger database auto lgr{std::make_unique( setup, LgrDBName, LgrDBPragma, LgrDBInit, checkpointerSetup)}; @@ -76,15 +78,38 @@ makeLedgerDBs( boost::format("PRAGMA cache_size=-%d;") % kilobytes(config.getValueFor(SizedItem::lgrDBCache))); + std::vector 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( 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) @@ -116,7 +141,9 @@ makeLedgerDBs( return {std::move(lgr), std::move(tx), true}; } else + { return {std::move(lgr), {}, true}; + } } std::optional diff --git a/src/ripple/app/rdb/backend/impl/SQLiteDatabase.cpp b/src/ripple/app/rdb/backend/impl/SQLiteDatabase.cpp index efeda85d723..2d595bbe86a 100644 --- a/src/ripple/app/rdb/backend/impl/SQLiteDatabase.cpp +++ b/src/ripple/app/rdb/backend/impl/SQLiteDatabase.cpp @@ -49,6 +49,17 @@ class SQLiteDatabaseImp : public SQLiteDatabase , useTxTables_(config.useTxTables()) , j_(app_.journal("SQLiteDatabaseImp")) { + std::cout << "SQLiteDatabaseImp - a" << std::endl; + + std::vector 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, @@ -61,6 +72,7 @@ class SQLiteDatabaseImp : public SQLiteDatabase JLOG(j_.fatal()) << error; Throw(error.data()); } + std::cout << "SQLiteDatabaseImp - b" << std::endl; if (app.getShardStore() && !makeMetaDBs( @@ -74,6 +86,7 @@ class SQLiteDatabaseImp : public SQLiteDatabase JLOG(j_.fatal()) << error; Throw(error.data()); } + std::cout << "SQLiteDatabaseImp - c" << std::endl; } std::optional @@ -448,6 +461,15 @@ SQLiteDatabaseImp::makeLedgerDBs( DatabaseCon::Setup const& setup, DatabaseCon::CheckpointerSetup const& checkpointerSetup) { + std::vector 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); diff --git a/src/ripple/app/rdb/impl/RelationalDatabase.cpp b/src/ripple/app/rdb/impl/RelationalDatabase.cpp index 8a3ce5b016d..f321ac53cce 100644 --- a/src/ripple/app/rdb/impl/RelationalDatabase.cpp +++ b/src/ripple/app/rdb/impl/RelationalDatabase.cpp @@ -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()) { @@ -64,6 +68,7 @@ RelationalDatabase::init( use_sqlite = true; } } + std::cout << "RelationalDatabase::init - d" << std::endl; if (use_sqlite) { @@ -73,6 +78,7 @@ RelationalDatabase::init( { return getPostgresDatabase(app, config, jobQueue); } + std::cout << "RelationalDatabase::init - e" << std::endl; return std::unique_ptr(); } diff --git a/src/ripple/core/DatabaseCon.h b/src/ripple/core/DatabaseCon.h index 59eec3a32e9..7c78bbaf09a 100644 --- a/src/ripple/core/DatabaseCon.h +++ b/src/ripple/core/DatabaseCon.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -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 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) @@ -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); }