// Connection maximum reconnect tries.
"max-reconnect-tries": 3,
+ // Disable DHCP on database connection loss.
+ "disable-dhcp-on-db-loss": true,
+
// Connection connect timeout.
"connect-timeout": 100,
"type": "mysql",
"reconnect-wait-time": 3000, // expressed in ms
"max-reconnect-tries": 3,
+ "disable-dhcp-on-db-loss": true,
"name": "kea",
"user": "kea",
"password": "kea",
"type": "postgresql",
"reconnect-wait-time": 3000, // expressed in ms
"max-reconnect-tries": 3,
+ "disable-dhcp-on-db-loss": true,
"name": "kea",
"user": "kea",
"password": "kea",
// Connection maximum reconnect tries.
"max-reconnect-tries": 3,
+ // Disable DHCP on database connection loss.
+ "disable-dhcp-on-db-loss": true,
+
// Connection connect timeout.
"connect-timeout": 100,
"type": "mysql",
"reconnect-wait-time": 3000, // expressed in ms
"max-reconnect-tries": 3,
+ "disable-dhcp-on-db-loss": true,
"name": "kea",
"user": "kea",
"password": "kea",
"type": "postgresql",
"reconnect-wait-time": 3000, // expressed in ms
"max-reconnect-tries": 3,
+ "disable-dhcp-on-db-loss": true,
"name": "kea",
"user": "kea",
"password": "kea",
recovery and causes the server to exit immediately upon detecting the
loss of connectivity. The default value for Cassandra is 2000 ms.
+::
+
+ "Dhcp4": { "lease-database": { "disable-dhcp-on-db-loss" : true, ... }, ... }
+
+The default value for MySQL and PostgreSQL is true, which disables the dhcp
+service while trying to automatically recover lost connections.
+
.. note::
Automatic reconnection to database backends is configured
recovery and causes the server to exit immediately upon detecting the
loss of connectivity. The default value for Cassandra is 2000 ms.
+ "Dhcp4": { "hosts-database": { "disable-dhcp-on-db-loss" : true, ... }, ... }
+
+The default value for MySQL and PostgreSQL is true, which disables the dhcp
+service while trying to automatically recover lost connections.
+
.. note::
Automatic reconnection to database backends is configured
recovery and causes the server to exit immediately upon detecting the
loss of connectivity. The default value for Cassandra is 2000 ms.
+ "Dhcp6": { "lease-database": { "disable-dhcp-on-db-loss" : true, ... }, ... }
+
+The default value for MySQL and PostgreSQL is true, which disables the dhcp
+service while trying to automatically recover lost connections.
+
.. note::
Automatic reconnection to database backends is configured
recovery and causes the server to exit immediately upon detecting the
loss of connectivity. The default value for Cassandra is 2000 ms.
+ "Dhcp6": { "hosts-database": { "disable-dhcp-on-db-loss" : true, ... }, ... }
+
+The default value for MySQL and PostgreSQL is true, which disables the dhcp
+service while trying to automatically recover lost connections.
+
.. note::
Automatic reconnection to database backends is configured
}
// Disable service until the connection is recovered.
- if (db_reconnect_ctl->retriesLeft() == db_reconnect_ctl->maxRetries()) {
+ if (db_reconnect_ctl->retriesLeft() == db_reconnect_ctl->maxRetries() &&
+ db_reconnect_ctl->disableDHCP()) {
network_state_->disableService(NetworkState::Origin::DB_CONNECTION);
}
bool
ControlledDhcpv4Srv::dbRecoveredCallback(ReconnectCtlPtr db_reconnect_ctl) {
- // Enable service after the connection is recovered.
- network_state_->enableService(NetworkState::Origin::DB_CONNECTION);
-
- LOG_INFO(dhcp4_logger, DHCP4_DB_RECONNECT_SUCCEEDED);
-
if (!db_reconnect_ctl) {
// This should never happen
LOG_ERROR(dhcp4_logger, DHCP4_DB_RECONNECT_NO_DB_CTL);
return (false);
}
+ // Enable service after the connection is recovered.
+ if (db_reconnect_ctl->disableDHCP()) {
+ network_state_->enableService(NetworkState::Origin::DB_CONNECTION);
+ }
+
+ LOG_INFO(dhcp4_logger, DHCP4_DB_RECONNECT_SUCCEEDED);
+
db_reconnect_ctl->resetRetries();
return (true);
}
}
+\"disable-dhcp-on-db-loss\" {
+ switch(driver.ctx_) {
+ case isc::dhcp::Parser4Context::LEASE_DATABASE:
+ case isc::dhcp::Parser4Context::HOSTS_DATABASE:
+ case isc::dhcp::Parser4Context::CONFIG_DATABASE:
+ return isc::dhcp::Dhcp4Parser::make_DISABLE_DHCP_ON_DB_LOSS(driver.loc_);
+ default:
+ return isc::dhcp::Dhcp4Parser::make_STRING("disable-dhcp-on-db-loss", driver.loc_);
+ }
+}
+
\"request-timeout\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::LEASE_DATABASE:
SERIAL_CONSISTENCY "serial-consistency"
MAX_RECONNECT_TRIES "max-reconnect-tries"
RECONNECT_WAIT_TIME "reconnect-wait-time"
+ DISABLE_DHCP_ON_DB_LOSS "disable-dhcp-on-db-loss"
REQUEST_TIMEOUT "request-timeout"
TCP_KEEPALIVE "tcp-keepalive"
TCP_NODELAY "tcp-nodelay"
| contact_points
| max_reconnect_tries
| reconnect_wait_time
+ | disable_dhcp_on_db_loss
| request_timeout
| tcp_keepalive
| tcp_nodelay
ctx.stack_.back()->set("reconnect-wait-time", n);
};
+disable_dhcp_on_db_loss: DISABLE_DHCP_ON_DB_LOSS COLON BOOLEAN {
+ ctx.unique("disable-dhcp-on-db-loss", ctx.loc2pos(@1));
+ ElementPtr n(new BoolElement($3, ctx.loc2pos(@3)));
+ ctx.stack_.back()->set("disable-dhcp-on-db-loss", n);
+};
+
max_row_errors: MAX_ROW_ERRORS COLON INTEGER {
ctx.unique("max-row-errors", ctx.loc2pos(@1));
ElementPtr n(new IntElement($3, ctx.loc2pos(@3)));
}
// Disable service until the connection is recovered.
- if (db_reconnect_ctl->retriesLeft() == db_reconnect_ctl->maxRetries()) {
+ if (db_reconnect_ctl->retriesLeft() == db_reconnect_ctl->maxRetries() &&
+ db_reconnect_ctl->disableDHCP()) {
network_state_->disableService(NetworkState::Origin::DB_CONNECTION);
}
bool
ControlledDhcpv6Srv::dbRecoveredCallback(ReconnectCtlPtr db_reconnect_ctl) {
- // Enable service after the connection is recovered.
- network_state_->enableService(NetworkState::Origin::DB_CONNECTION);
-
- LOG_INFO(dhcp6_logger, DHCP6_DB_RECONNECT_SUCCEEDED);
-
if (!db_reconnect_ctl) {
// This should never happen
LOG_ERROR(dhcp6_logger, DHCP6_DB_RECONNECT_NO_DB_CTL);
return (false);
}
+ // Enable service after the connection is recovered.
+ if (db_reconnect_ctl->disableDHCP()) {
+ network_state_->enableService(NetworkState::Origin::DB_CONNECTION);
+ }
+
+ LOG_INFO(dhcp6_logger, DHCP6_DB_RECONNECT_SUCCEEDED);
+
db_reconnect_ctl->resetRetries();
return (true);
}
}
+\"disable-dhcp-on-db-loss\" {
+ switch(driver.ctx_) {
+ case isc::dhcp::Parser6Context::LEASE_DATABASE:
+ case isc::dhcp::Parser6Context::HOSTS_DATABASE:
+ case isc::dhcp::Parser6Context::CONFIG_DATABASE:
+ return isc::dhcp::Dhcp6Parser::make_DISABLE_DHCP_ON_DB_LOSS(driver.loc_);
+ default:
+ return isc::dhcp::Dhcp6Parser::make_STRING("disable-dhcp-on-db-loss", driver.loc_);
+ }
+}
+
\"request-timeout\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::LEASE_DATABASE:
CONTACT_POINTS "contact-points"
MAX_RECONNECT_TRIES "max-reconnect-tries"
RECONNECT_WAIT_TIME "reconnect-wait-time"
+ DISABLE_DHCP_ON_DB_LOSS "disable-dhcp-on-db-loss"
KEYSPACE "keyspace"
CONSISTENCY "consistency"
SERIAL_CONSISTENCY "serial-consistency"
| contact_points
| max_reconnect_tries
| reconnect_wait_time
+ | disable_dhcp_on_db_loss
| request_timeout
| tcp_keepalive
| tcp_nodelay
ctx.stack_.back()->set("reconnect-wait-time", n);
};
+disable_dhcp_on_db_loss: DISABLE_DHCP_ON_DB_LOSS COLON BOOLEAN {
+ ctx.unique("disable-dhcp-on-db-loss", ctx.loc2pos(@1));
+ ElementPtr n(new BoolElement($3, ctx.loc2pos(@3)));
+ ctx.stack_.back()->set("disable-dhcp-on-db-loss", n);
+};
+
max_row_errors: MAX_ROW_ERRORS COLON INTEGER {
ctx.unique("max-row-errors", ctx.loc2pos(@1));
ElementPtr n(new IntElement($3, ctx.loc2pos(@3)));
// Wasn't specified so we'll use default of 0;
}
+ bool disable_dhcp = true;
+ try {
+ parm_str = getParameter("disable-dhcp-on-db-loss");
+ disable_dhcp = boost::lexical_cast<bool>(parm_str);
+ } catch (...) {
+ // Wasn't specified so we'll use default of true;
+ }
+
reconnect_ctl_ = boost::make_shared<ReconnectCtl>(type, timer_name, retries,
- interval);
+ interval, disable_dhcp);
}
bool
}
} else if ((keyword == "persist") ||
(keyword == "tcp-nodelay") ||
- (keyword == "readonly")) {
+ (keyword == "readonly") ||
+ (keyword == "disable-dhcp-on-db-loss")) {
if (value == "true") {
result->set(keyword, isc::data::Element::create(true));
} else if (value == "false") {
/// @param max_retries maximum number of reconnect attempts to make
/// @param retry_interval amount of time to between reconnect attempts
ReconnectCtl(const std::string& backend_type, const std::string& timer_name,
- unsigned int max_retries, unsigned int retry_interval)
- : backend_type_(backend_type), timer_name_(timer_name),
- max_retries_(max_retries), retries_left_(max_retries),
- retry_interval_(retry_interval) {}
+ unsigned int max_retries, unsigned int retry_interval,
+ bool disable_dhcp) : backend_type_(backend_type),
+ timer_name_(timer_name), max_retries_(max_retries),
+ retries_left_(max_retries), retry_interval_(retry_interval),
+ disable_dhcp_(disable_dhcp) {}
/// @brief Returns the type of the caller backend.
std::string backendType() const {
retries_left_ = max_retries_;
}
+ /// @brief Return the flag which indicates if the connection loss should
+ /// disable the dhcp service.
+ bool disableDHCP() {
+ return (disable_dhcp_);
+ }
+
private:
/// @brief Caller backend type.
/// @brief The amount of time to wait between reconnect attempts
unsigned int retry_interval_;
+
+ /// @brief Flag which indicates if the connection loss should disable the
+ /// dhcp service.
+ bool disable_dhcp_;
};
/// @brief Pointer to an instance of ReconnectCtl
try {
if ((param.first == "persist") ||
(param.first == "tcp-nodelay") ||
- (param.first == "readonly")) {
+ (param.first == "readonly") ||
+ (param.first == "disable-dhcp-on-db-loss")) {
values_copy[param.first] = (param.second->boolValue() ?
"true" : "false");
<< "(" << value->getPosition() << ")");
}
- if ((reconnect_wait_time < 0) ||
- (reconnect_wait_time > std::numeric_limits<uint32_t>::max())) {
- ConstElementPtr value = database_config->get("reconnect-wait-time");
- isc_throw(DbConfigError, "reconnect-wait-time " << reconnect_wait_time
- << " must be in range 0...MAX_UINT32 (4294967295) "
- << "(" << value->getPosition() << ")");
- }
-
// Check that tcp_keepalive value makes sense.
if ((tcp_keepalive < 0) ||
(tcp_keepalive > std::numeric_limits<uint32_t>::max())) {