summaryrefslogtreecommitdiffstats
path: root/src/lib/mysql
diff options
context:
space:
mode:
authorAndrei Pavel <andrei@isc.org>2024-02-13 18:17:57 +0100
committerAndrei Pavel <andrei@isc.org>2024-02-22 08:57:35 +0100
commita7d471912e61ee290f930d8685fc80503ea69320 (patch)
treee80b708c800502d44f337bf6cde09f08c5e502af /src/lib/mysql
parent[#3025] switch io service to DatabaseConnection's (diff)
downloadkea-a7d471912e61ee290f930d8685fc80503ea69320.tar.xz
kea-a7d471912e61ee290f930d8685fc80503ea69320.zip
[#3025] add db init on startup to other managers
Diffstat (limited to 'src/lib/mysql')
-rw-r--r--src/lib/mysql/mysql_connection.cc14
-rw-r--r--src/lib/mysql/mysql_connection.h5
2 files changed, 15 insertions, 4 deletions
diff --git a/src/lib/mysql/mysql_connection.cc b/src/lib/mysql/mysql_connection.cc
index aee087e266..206c069450 100644
--- a/src/lib/mysql/mysql_connection.cc
+++ b/src/lib/mysql/mysql_connection.cc
@@ -371,9 +371,19 @@ MySqlConnection::getVersion(const ParameterMap& parameters,
void
MySqlConnection::ensureSchemaVersion(const ParameterMap& parameters,
- const IOServiceAccessorPtr& ac,
const DbCallback& cb,
- const string& timer_name) {
+ string timer_name) {
+ // retry-on-startup?
+ bool const retry(parameters.count("retry-on-startup") &&
+ parameters.at("retry-on-startup") == "true");
+ if (!retry) {
+ // If not, then we need timer_name to be empty to signal that retrying
+ // is not desired.
+ timer_name = string();
+ }
+
+ IOServiceAccessorPtr ac(new IOServiceAccessor(&DatabaseConnection::getIOService));
+
pair<uint32_t, uint32_t> schema_version;
try {
schema_version = getVersion(parameters, ac, cb, timer_name);
diff --git a/src/lib/mysql/mysql_connection.h b/src/lib/mysql/mysql_connection.h
index d7a3ce5dfc..410aaa2de5 100644
--- a/src/lib/mysql/mysql_connection.h
+++ b/src/lib/mysql/mysql_connection.h
@@ -282,15 +282,16 @@ public:
/// version, and attempt to initialize the schema if there is an
/// error during retrieval.
///
+ /// Properly handles retrying of the database connection.
+ ///
/// @param parameters A data structure relating keywords and values
/// concerned with the database.
///
/// @throw isc::db::ScehamInitializationFailed if the initialization fails
static void
ensureSchemaVersion(const ParameterMap& parameters,
- const IOServiceAccessorPtr& ac = IOServiceAccessorPtr(),
const DbCallback& cb = DbCallback(),
- const std::string& timer_name = std::string());
+ std::string timer_name = std::string());
/// @brief Initialize schema.
///