93 Throw<std::runtime_error>(
"database_path must be set.");
99 auto const& sqlite = c.
section(
"sqlite");
108 bool showRiskWarning =
false;
110 if (
set(safety_level,
"safety_level", sqlite))
112 if (boost::iequals(safety_level,
"low"))
115 journal_mode =
"memory";
117 temp_store =
"memory";
118 showRiskWarning =
true;
120 else if (!boost::iequals(safety_level,
"high"))
122 Throw<std::runtime_error>(
"Invalid safety_level value: " + safety_level);
129 if (
set(journal_mode,
"journal_mode", sqlite) && !safety_level.
empty())
131 Throw<std::runtime_error>(
132 "Configuration file may not define both "
133 "\"safety_level\" and \"journal_mode\"");
135 bool higherRisk = boost::iequals(journal_mode,
"memory") || boost::iequals(journal_mode,
"off");
136 showRiskWarning = showRiskWarning || higherRisk;
137 if (higherRisk || boost::iequals(journal_mode,
"delete") || boost::iequals(journal_mode,
"truncate") ||
138 boost::iequals(journal_mode,
"persist") || boost::iequals(journal_mode,
"wal"))
144 Throw<std::runtime_error>(
"Invalid journal_mode value: " + journal_mode);
150 if (
set(synchronous,
"synchronous", sqlite) && !safety_level.
empty())
152 Throw<std::runtime_error>(
153 "Configuration file may not define both "
154 "\"safety_level\" and \"synchronous\"");
156 bool higherRisk = boost::iequals(synchronous,
"off");
157 showRiskWarning = showRiskWarning || higherRisk;
158 if (higherRisk || boost::iequals(synchronous,
"normal") || boost::iequals(synchronous,
"full") ||
159 boost::iequals(synchronous,
"extra"))
165 Throw<std::runtime_error>(
"Invalid synchronous value: " + synchronous);
171 if (
set(temp_store,
"temp_store", sqlite) && !safety_level.
empty())
173 Throw<std::runtime_error>(
174 "Configuration file may not define both "
175 "\"safety_level\" and \"temp_store\"");
177 bool higherRisk = boost::iequals(temp_store,
"memory");
178 showRiskWarning = showRiskWarning || higherRisk;
179 if (higherRisk || boost::iequals(temp_store,
"default") || boost::iequals(temp_store,
"file"))
185 Throw<std::runtime_error>(
"Invalid temp_store value: " + temp_store);
191 JLOG(j->warn()) <<
"reducing the data integrity guarantees from the "
192 "default [sqlite] behavior is not recommended for "
193 "nodes storing large amounts of history, because of the "
194 "difficulty inherent in rebuilding corrupted data.";
196 XRPL_ASSERT(result->size() == 3,
"xrpl::setup_DatabaseCon::globalPragma : result size is 3");
207 setPragma(setup.
lgrPragma[0],
"journal_size_limit", 1582080);
210 int64_t page_size = 4096;
211 int64_t journal_size_limit = 1582080;
215 set(journal_size_limit,
"journal_size_limit", s);
216 set(page_size,
"page_size", s);
217 if (page_size < 512 || page_size > 65536)
218 Throw<std::runtime_error>(
"Invalid page_size. Must be between 512 and 65536.");
220 if (page_size & (page_size - 1))
221 Throw<std::runtime_error>(
"Invalid page_size. Must be a power of 2.");
224 setPragma(setup.
txPragma[0],
"page_size", page_size);
225 setPragma(setup.
txPragma[1],
"journal_size_limit", journal_size_limit);
226 setPragma(setup.
txPragma[2],
"max_page_count", 4294967294);
227 setPragma(setup.
txPragma[3],
"mmap_size", 17179869184);
bool set(T &target, std::string const &name, Section const §ion)
Set a value from a configuration Section If the named value is not found or doesn't parse as a T,...
std::shared_ptr< Checkpointer > makeCheckpointer(std::uintptr_t id, std::weak_ptr< soci::session > session, JobQueue &queue, Logs &logs)
Returns a new checkpointer which makes checkpoints of a soci database every checkpointPageCount pages...