116 Throw<std::runtime_error>(
"database_path must be set.");
122 auto const& sqlite = c.
section(
"sqlite");
131 bool showRiskWarning =
false;
133 if (
set(safety_level,
"safety_level", sqlite))
135 if (boost::iequals(safety_level,
"low"))
138 journal_mode =
"memory";
140 temp_store =
"memory";
141 showRiskWarning =
true;
143 else if (!boost::iequals(safety_level,
"high"))
145 Throw<std::runtime_error>(
146 "Invalid safety_level value: " + safety_level);
153 if (
set(journal_mode,
"journal_mode", sqlite) &&
154 !safety_level.
empty())
156 Throw<std::runtime_error>(
157 "Configuration file may not define both "
158 "\"safety_level\" and \"journal_mode\"");
160 bool higherRisk = boost::iequals(journal_mode,
"memory") ||
161 boost::iequals(journal_mode,
"off");
162 showRiskWarning = showRiskWarning || higherRisk;
163 if (higherRisk || boost::iequals(journal_mode,
"delete") ||
164 boost::iequals(journal_mode,
"truncate") ||
165 boost::iequals(journal_mode,
"persist") ||
166 boost::iequals(journal_mode,
"wal"))
168 result->emplace_back(boost::str(
173 Throw<std::runtime_error>(
174 "Invalid journal_mode value: " + journal_mode);
180 if (
set(synchronous,
"synchronous", sqlite) &&
181 !safety_level.
empty())
183 Throw<std::runtime_error>(
184 "Configuration file may not define both "
185 "\"safety_level\" and \"synchronous\"");
187 bool higherRisk = boost::iequals(synchronous,
"off");
188 showRiskWarning = showRiskWarning || higherRisk;
189 if (higherRisk || boost::iequals(synchronous,
"normal") ||
190 boost::iequals(synchronous,
"full") ||
191 boost::iequals(synchronous,
"extra"))
193 result->emplace_back(boost::str(
198 Throw<std::runtime_error>(
199 "Invalid synchronous value: " + synchronous);
205 if (
set(temp_store,
"temp_store", sqlite) &&
206 !safety_level.
empty())
208 Throw<std::runtime_error>(
209 "Configuration file may not define both "
210 "\"safety_level\" and \"temp_store\"");
212 bool higherRisk = boost::iequals(temp_store,
"memory");
213 showRiskWarning = showRiskWarning || higherRisk;
214 if (higherRisk || boost::iequals(temp_store,
"default") ||
215 boost::iequals(temp_store,
"file"))
217 result->emplace_back(boost::str(
222 Throw<std::runtime_error>(
223 "Invalid temp_store value: " + temp_store);
230 <<
"reducing the data integrity guarantees from the "
231 "default [sqlite] behavior is not recommended for "
232 "nodes storing large amounts of history, because of the "
233 "difficulty inherent in rebuilding corrupted data.";
237 "ripple::setup_DatabaseCon::globalPragma : result size is 3");
249 setPragma(setup.
lgrPragma[0],
"journal_size_limit", 1582080);
252 int64_t page_size = 4096;
253 int64_t journal_size_limit = 1582080;
257 set(journal_size_limit,
"journal_size_limit", s);
258 set(page_size,
"page_size", s);
259 if (page_size < 512 || page_size > 65536)
260 Throw<std::runtime_error>(
261 "Invalid page_size. Must be between 512 and 65536.");
263 if (page_size & (page_size - 1))
264 Throw<std::runtime_error>(
265 "Invalid page_size. Must be a power of 2.");
268 setPragma(setup.
txPragma[0],
"page_size", page_size);
269 setPragma(setup.
txPragma[1],
"journal_size_limit", journal_size_limit);
270 setPragma(setup.
txPragma[2],
"max_page_count", 4294967294);
271 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...