--- /dev/null
+[bug] tmark
+ Treat allocator initializition failures caused
+ by database connectivity issues as a recoverable
+ condition. Prior to this the server would exit
+ with a fatal error even when configure to retry.
+ Applies to both kea-dhcp4 and kea-dhcp6 when
+ using either the FLQ or SLFQ allocators.
+ (Gitlab #4508)
return (isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str()));
}
+ // Enable allocator initialization prior to creating lease manager.
+ LeaseMgrFactory::init_allocators_ = true;
+
// Re-open lease and host database with new parameters.
try {
DatabaseConnection::db_lost_callback_ =
return (notify_libraries);
}
- // Initialize the allocators. If the user selected a Free Lease Queue Allocator
- // for any of the subnets, the server will now populate free leases to the queue.
- // It may take a while!
- try {
- CfgMgr::instance().getStagingCfg()->getCfgSubnets4()->initAllocatorsAfterConfigure();
-
- } catch (const std::exception& ex) {
- err << "Error initializing the lease allocators: "
- << ex.what();
- return (isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str()));
- }
-
// Apply multi threading settings.
// @note These settings are applied/updated only if no errors occur while
// applying the new configuration.
return (isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str()));
}
+ // Enable allocator initialization prior to creating lease manager.
+ LeaseMgrFactory::init_allocators_ = true;
+
// Re-open lease and host database with new parameters.
try {
DatabaseConnection::db_lost_callback_ =
return (notify_libraries);
}
- // Initialize the allocators. If the user selected a Free Lease Queue Allocator
- // for any of the subnets, the server will now populate free leases to the queue.
- // It may take a while!
- try {
- CfgMgr::instance().getStagingCfg()->getCfgSubnets6()->initAllocatorsAfterConfigure();
-
- } catch (const std::exception& ex) {
- err << "Error initializing the lease allocators: "
- << ex.what();
- return (isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str()));
- }
-
// Apply multi threading settings.
// @note These settings are applied/updated only if no errors occur while
// applying the new configuration.
#include <config.h>
+#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/dhcpsrv_log.h>
#include <dhcpsrv/lease_mgr_factory.h>
#include <dhcpsrv/memfile_lease_mgr.h>
return (lease_mgr_ptr);
}
+bool LeaseMgrFactory::init_allocators_ = false;
+
+void
+LeaseMgrFactory::initAllocators(bool use_staging /* = false */) {
+ if (!LeaseMgrFactory::init_allocators_) {
+ return;
+ }
+ auto cfg = (use_staging ? CfgMgr::instance().getStagingCfg()
+ : CfgMgr::instance().getCurrentCfg());
+ if (CfgMgr::instance().getFamily() == AF_INET) {
+ cfg->getCfgSubnets4()->initAllocatorsAfterConfigure();
+ } else {
+ cfg->getCfgSubnets6()->initAllocatorsAfterConfigure();
+ }
+ LeaseMgrFactory::init_allocators_ = false;
+}
+
void
LeaseMgrFactory::create(const std::string& dbaccess) {
const std::string type = "type";
destroy();
create(dbaccess);
+ // Init lease allocators. We do this here for allocators which require
+ // the lease manager access (i.e. SFLQ and FLQ) for initialization.
+ // When preserve_callbacks is true are using the a current configuration.
+ // If it is false we are using staging. Pass the inverse to initAllocators().
+ LeaseMgrFactory::initAllocators(!preserve_callbacks);
+
if (callbacks) {
// Copy the callbacks to the new instance. It should be fast
// because we merely copy the pointer.
/// @brief Return extended version info for registered backends.
static std::list<std::string> getDBVersions();
+ /// @brief Initializes the lease allocators for all subnets.
+ /// @param use_staging Use the staging configuration when true, otherwise
+ /// use the current configuration. Defaults to false.
+ static void initAllocators(bool use_staging = false);
+
+ /// @brief Flag which indicates if allocators must be initialized.
+ static bool init_allocators_;
+
private:
/// @brief Hold pointer to lease manager
///