2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 14:05:33 +00:00

[5477] dhcpsrv/postgres and kea-dhcp4 now support db reconnect

kea-dhcp4
    added support for max-reconnect-tries and reconnect-wait-time
    to lease and host db parsers

    Added a callback for when DB backends detect loss of connectivity

    Added a self-rescheduling method to attempt to reconnect to the
    backends if retries are enabled

dhcpsrv
    Added a callback that DatabaseConnection derivations should invoke
    when they lose connectivity.

    Added an optional callback parameter from CfgDbAccess::createManagers()
    all the way down to DatabaseConnection ctor.

    pgsql_connection.cc
        PgSqlConnection::~PgSqlConnection() - Added logic to close the
        connection only when the connect state is still OK.
        Otherwise it likes to core dump.

        PgSqlConnection::checkStatementError() - Modified to invoke the
        connectivity lost callback on "fatal" errors

    pgsql_lease_mgr_unittest.cc
    pgsql_host_data_source_unittest.cc
        Added tests to verify that the lost callback is NOT invoked on an
        open failure
This commit is contained in:
Thomas Markwalder
2018-02-28 15:29:23 -05:00
parent f124d85d24
commit 249219f1fc
34 changed files with 3645 additions and 3318 deletions

View File

@@ -387,116 +387,118 @@ namespace isc { namespace dhcp {
TOKEN_CONNECT_TIMEOUT = 294,
TOKEN_CONTACT_POINTS = 295,
TOKEN_KEYSPACE = 296,
TOKEN_VALID_LIFETIME = 297,
TOKEN_RENEW_TIMER = 298,
TOKEN_REBIND_TIMER = 299,
TOKEN_DECLINE_PROBATION_PERIOD = 300,
TOKEN_SUBNET4 = 301,
TOKEN_SUBNET_4O6_INTERFACE = 302,
TOKEN_SUBNET_4O6_INTERFACE_ID = 303,
TOKEN_SUBNET_4O6_SUBNET = 304,
TOKEN_OPTION_DEF = 305,
TOKEN_OPTION_DATA = 306,
TOKEN_NAME = 307,
TOKEN_DATA = 308,
TOKEN_CODE = 309,
TOKEN_SPACE = 310,
TOKEN_CSV_FORMAT = 311,
TOKEN_ALWAYS_SEND = 312,
TOKEN_RECORD_TYPES = 313,
TOKEN_ENCAPSULATE = 314,
TOKEN_ARRAY = 315,
TOKEN_SHARED_NETWORKS = 316,
TOKEN_POOLS = 317,
TOKEN_POOL = 318,
TOKEN_USER_CONTEXT = 319,
TOKEN_COMMENT = 320,
TOKEN_SUBNET = 321,
TOKEN_INTERFACE = 322,
TOKEN_INTERFACE_ID = 323,
TOKEN_ID = 324,
TOKEN_RAPID_COMMIT = 325,
TOKEN_RESERVATION_MODE = 326,
TOKEN_DISABLED = 327,
TOKEN_OUT_OF_POOL = 328,
TOKEN_ALL = 329,
TOKEN_HOST_RESERVATION_IDENTIFIERS = 330,
TOKEN_CLIENT_CLASSES = 331,
TOKEN_TEST = 332,
TOKEN_CLIENT_CLASS = 333,
TOKEN_RESERVATIONS = 334,
TOKEN_DUID = 335,
TOKEN_HW_ADDRESS = 336,
TOKEN_CIRCUIT_ID = 337,
TOKEN_CLIENT_ID = 338,
TOKEN_HOSTNAME = 339,
TOKEN_FLEX_ID = 340,
TOKEN_RELAY = 341,
TOKEN_IP_ADDRESS = 342,
TOKEN_HOOKS_LIBRARIES = 343,
TOKEN_LIBRARY = 344,
TOKEN_PARAMETERS = 345,
TOKEN_EXPIRED_LEASES_PROCESSING = 346,
TOKEN_RECLAIM_TIMER_WAIT_TIME = 347,
TOKEN_FLUSH_RECLAIMED_TIMER_WAIT_TIME = 348,
TOKEN_HOLD_RECLAIMED_TIME = 349,
TOKEN_MAX_RECLAIM_LEASES = 350,
TOKEN_MAX_RECLAIM_TIME = 351,
TOKEN_UNWARNED_RECLAIM_CYCLES = 352,
TOKEN_DHCP4O6_PORT = 353,
TOKEN_CONTROL_SOCKET = 354,
TOKEN_SOCKET_TYPE = 355,
TOKEN_SOCKET_NAME = 356,
TOKEN_DHCP_DDNS = 357,
TOKEN_ENABLE_UPDATES = 358,
TOKEN_QUALIFYING_SUFFIX = 359,
TOKEN_SERVER_IP = 360,
TOKEN_SERVER_PORT = 361,
TOKEN_SENDER_IP = 362,
TOKEN_SENDER_PORT = 363,
TOKEN_MAX_QUEUE_SIZE = 364,
TOKEN_NCR_PROTOCOL = 365,
TOKEN_NCR_FORMAT = 366,
TOKEN_ALWAYS_INCLUDE_FQDN = 367,
TOKEN_OVERRIDE_NO_UPDATE = 368,
TOKEN_OVERRIDE_CLIENT_UPDATE = 369,
TOKEN_REPLACE_CLIENT_NAME = 370,
TOKEN_GENERATED_PREFIX = 371,
TOKEN_TCP = 372,
TOKEN_JSON = 373,
TOKEN_WHEN_PRESENT = 374,
TOKEN_NEVER = 375,
TOKEN_ALWAYS = 376,
TOKEN_WHEN_NOT_PRESENT = 377,
TOKEN_LOGGING = 378,
TOKEN_LOGGERS = 379,
TOKEN_OUTPUT_OPTIONS = 380,
TOKEN_OUTPUT = 381,
TOKEN_DEBUGLEVEL = 382,
TOKEN_SEVERITY = 383,
TOKEN_FLUSH = 384,
TOKEN_MAXSIZE = 385,
TOKEN_MAXVER = 386,
TOKEN_DHCP6 = 387,
TOKEN_DHCPDDNS = 388,
TOKEN_CONTROL_AGENT = 389,
TOKEN_TOPLEVEL_JSON = 390,
TOKEN_TOPLEVEL_DHCP4 = 391,
TOKEN_SUB_DHCP4 = 392,
TOKEN_SUB_INTERFACES4 = 393,
TOKEN_SUB_SUBNET4 = 394,
TOKEN_SUB_POOL4 = 395,
TOKEN_SUB_RESERVATION = 396,
TOKEN_SUB_OPTION_DEFS = 397,
TOKEN_SUB_OPTION_DEF = 398,
TOKEN_SUB_OPTION_DATA = 399,
TOKEN_SUB_HOOKS_LIBRARY = 400,
TOKEN_SUB_DHCP_DDNS = 401,
TOKEN_SUB_LOGGING = 402,
TOKEN_STRING = 403,
TOKEN_INTEGER = 404,
TOKEN_FLOAT = 405,
TOKEN_BOOLEAN = 406
TOKEN_MAX_RECONNECT_TRIES = 297,
TOKEN_RECONNECT_WAIT_TIME = 298,
TOKEN_VALID_LIFETIME = 299,
TOKEN_RENEW_TIMER = 300,
TOKEN_REBIND_TIMER = 301,
TOKEN_DECLINE_PROBATION_PERIOD = 302,
TOKEN_SUBNET4 = 303,
TOKEN_SUBNET_4O6_INTERFACE = 304,
TOKEN_SUBNET_4O6_INTERFACE_ID = 305,
TOKEN_SUBNET_4O6_SUBNET = 306,
TOKEN_OPTION_DEF = 307,
TOKEN_OPTION_DATA = 308,
TOKEN_NAME = 309,
TOKEN_DATA = 310,
TOKEN_CODE = 311,
TOKEN_SPACE = 312,
TOKEN_CSV_FORMAT = 313,
TOKEN_ALWAYS_SEND = 314,
TOKEN_RECORD_TYPES = 315,
TOKEN_ENCAPSULATE = 316,
TOKEN_ARRAY = 317,
TOKEN_SHARED_NETWORKS = 318,
TOKEN_POOLS = 319,
TOKEN_POOL = 320,
TOKEN_USER_CONTEXT = 321,
TOKEN_COMMENT = 322,
TOKEN_SUBNET = 323,
TOKEN_INTERFACE = 324,
TOKEN_INTERFACE_ID = 325,
TOKEN_ID = 326,
TOKEN_RAPID_COMMIT = 327,
TOKEN_RESERVATION_MODE = 328,
TOKEN_DISABLED = 329,
TOKEN_OUT_OF_POOL = 330,
TOKEN_ALL = 331,
TOKEN_HOST_RESERVATION_IDENTIFIERS = 332,
TOKEN_CLIENT_CLASSES = 333,
TOKEN_TEST = 334,
TOKEN_CLIENT_CLASS = 335,
TOKEN_RESERVATIONS = 336,
TOKEN_DUID = 337,
TOKEN_HW_ADDRESS = 338,
TOKEN_CIRCUIT_ID = 339,
TOKEN_CLIENT_ID = 340,
TOKEN_HOSTNAME = 341,
TOKEN_FLEX_ID = 342,
TOKEN_RELAY = 343,
TOKEN_IP_ADDRESS = 344,
TOKEN_HOOKS_LIBRARIES = 345,
TOKEN_LIBRARY = 346,
TOKEN_PARAMETERS = 347,
TOKEN_EXPIRED_LEASES_PROCESSING = 348,
TOKEN_RECLAIM_TIMER_WAIT_TIME = 349,
TOKEN_FLUSH_RECLAIMED_TIMER_WAIT_TIME = 350,
TOKEN_HOLD_RECLAIMED_TIME = 351,
TOKEN_MAX_RECLAIM_LEASES = 352,
TOKEN_MAX_RECLAIM_TIME = 353,
TOKEN_UNWARNED_RECLAIM_CYCLES = 354,
TOKEN_DHCP4O6_PORT = 355,
TOKEN_CONTROL_SOCKET = 356,
TOKEN_SOCKET_TYPE = 357,
TOKEN_SOCKET_NAME = 358,
TOKEN_DHCP_DDNS = 359,
TOKEN_ENABLE_UPDATES = 360,
TOKEN_QUALIFYING_SUFFIX = 361,
TOKEN_SERVER_IP = 362,
TOKEN_SERVER_PORT = 363,
TOKEN_SENDER_IP = 364,
TOKEN_SENDER_PORT = 365,
TOKEN_MAX_QUEUE_SIZE = 366,
TOKEN_NCR_PROTOCOL = 367,
TOKEN_NCR_FORMAT = 368,
TOKEN_ALWAYS_INCLUDE_FQDN = 369,
TOKEN_OVERRIDE_NO_UPDATE = 370,
TOKEN_OVERRIDE_CLIENT_UPDATE = 371,
TOKEN_REPLACE_CLIENT_NAME = 372,
TOKEN_GENERATED_PREFIX = 373,
TOKEN_TCP = 374,
TOKEN_JSON = 375,
TOKEN_WHEN_PRESENT = 376,
TOKEN_NEVER = 377,
TOKEN_ALWAYS = 378,
TOKEN_WHEN_NOT_PRESENT = 379,
TOKEN_LOGGING = 380,
TOKEN_LOGGERS = 381,
TOKEN_OUTPUT_OPTIONS = 382,
TOKEN_OUTPUT = 383,
TOKEN_DEBUGLEVEL = 384,
TOKEN_SEVERITY = 385,
TOKEN_FLUSH = 386,
TOKEN_MAXSIZE = 387,
TOKEN_MAXVER = 388,
TOKEN_DHCP6 = 389,
TOKEN_DHCPDDNS = 390,
TOKEN_CONTROL_AGENT = 391,
TOKEN_TOPLEVEL_JSON = 392,
TOKEN_TOPLEVEL_DHCP4 = 393,
TOKEN_SUB_DHCP4 = 394,
TOKEN_SUB_INTERFACES4 = 395,
TOKEN_SUB_SUBNET4 = 396,
TOKEN_SUB_POOL4 = 397,
TOKEN_SUB_RESERVATION = 398,
TOKEN_SUB_OPTION_DEFS = 399,
TOKEN_SUB_OPTION_DEF = 400,
TOKEN_SUB_OPTION_DATA = 401,
TOKEN_SUB_HOOKS_LIBRARY = 402,
TOKEN_SUB_DHCP_DDNS = 403,
TOKEN_SUB_LOGGING = 404,
TOKEN_STRING = 405,
TOKEN_INTEGER = 406,
TOKEN_FLOAT = 407,
TOKEN_BOOLEAN = 408
};
};
@@ -771,6 +773,14 @@ namespace isc { namespace dhcp {
symbol_type
make_KEYSPACE (const location_type& l);
static inline
symbol_type
make_MAX_RECONNECT_TRIES (const location_type& l);
static inline
symbol_type
make_RECONNECT_WAIT_TIME (const location_type& l);
static inline
symbol_type
make_VALID_LIFETIME (const location_type& l);
@@ -1416,12 +1426,12 @@ namespace isc { namespace dhcp {
enum
{
yyeof_ = 0,
yylast_ = 892, ///< Last index in yytable_.
yynnts_ = 337, ///< Number of nonterminal symbols.
yylast_ = 900, ///< Last index in yytable_.
yynnts_ = 339, ///< Number of nonterminal symbols.
yyfinal_ = 28, ///< Termination state number.
yyterror_ = 1,
yyerrcode_ = 256,
yyntokens_ = 152 ///< Number of tokens.
yyntokens_ = 154 ///< Number of tokens.
};
@@ -1478,9 +1488,9 @@ namespace isc { namespace dhcp {
115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
145, 146, 147, 148, 149, 150, 151
145, 146, 147, 148, 149, 150, 151, 152, 153
};
const unsigned int user_token_number_max_ = 406;
const unsigned int user_token_number_max_ = 408;
const token_number_type undef_token_ = 2;
if (static_cast<int>(t) <= yyeof_)
@@ -1513,30 +1523,30 @@ namespace isc { namespace dhcp {
{
switch (other.type_get ())
{
case 167: // value
case 171: // map_value
case 209: // socket_type
case 212: // outbound_interface_value
case 222: // db_type
case 299: // hr_mode
case 444: // ncr_protocol_value
case 452: // replace_client_name_value
case 169: // value
case 173: // map_value
case 211: // socket_type
case 214: // outbound_interface_value
case 224: // db_type
case 303: // hr_mode
case 448: // ncr_protocol_value
case 456: // replace_client_name_value
value.copy< ElementPtr > (other.value);
break;
case 151: // "boolean"
case 153: // "boolean"
value.copy< bool > (other.value);
break;
case 150: // "floating point"
case 152: // "floating point"
value.copy< double > (other.value);
break;
case 149: // "integer"
case 151: // "integer"
value.copy< int64_t > (other.value);
break;
case 148: // "constant string"
case 150: // "constant string"
value.copy< std::string > (other.value);
break;
@@ -1557,30 +1567,30 @@ namespace isc { namespace dhcp {
(void) v;
switch (this->type_get ())
{
case 167: // value
case 171: // map_value
case 209: // socket_type
case 212: // outbound_interface_value
case 222: // db_type
case 299: // hr_mode
case 444: // ncr_protocol_value
case 452: // replace_client_name_value
case 169: // value
case 173: // map_value
case 211: // socket_type
case 214: // outbound_interface_value
case 224: // db_type
case 303: // hr_mode
case 448: // ncr_protocol_value
case 456: // replace_client_name_value
value.copy< ElementPtr > (v);
break;
case 151: // "boolean"
case 153: // "boolean"
value.copy< bool > (v);
break;
case 150: // "floating point"
case 152: // "floating point"
value.copy< double > (v);
break;
case 149: // "integer"
case 151: // "integer"
value.copy< int64_t > (v);
break;
case 148: // "constant string"
case 150: // "constant string"
value.copy< std::string > (v);
break;
@@ -1660,30 +1670,30 @@ namespace isc { namespace dhcp {
// Type destructor.
switch (yytype)
{
case 167: // value
case 171: // map_value
case 209: // socket_type
case 212: // outbound_interface_value
case 222: // db_type
case 299: // hr_mode
case 444: // ncr_protocol_value
case 452: // replace_client_name_value
case 169: // value
case 173: // map_value
case 211: // socket_type
case 214: // outbound_interface_value
case 224: // db_type
case 303: // hr_mode
case 448: // ncr_protocol_value
case 456: // replace_client_name_value
value.template destroy< ElementPtr > ();
break;
case 151: // "boolean"
case 153: // "boolean"
value.template destroy< bool > ();
break;
case 150: // "floating point"
case 152: // "floating point"
value.template destroy< double > ();
break;
case 149: // "integer"
case 151: // "integer"
value.template destroy< int64_t > ();
break;
case 148: // "constant string"
case 150: // "constant string"
value.template destroy< std::string > ();
break;
@@ -1710,30 +1720,30 @@ namespace isc { namespace dhcp {
super_type::move(s);
switch (this->type_get ())
{
case 167: // value
case 171: // map_value
case 209: // socket_type
case 212: // outbound_interface_value
case 222: // db_type
case 299: // hr_mode
case 444: // ncr_protocol_value
case 452: // replace_client_name_value
case 169: // value
case 173: // map_value
case 211: // socket_type
case 214: // outbound_interface_value
case 224: // db_type
case 303: // hr_mode
case 448: // ncr_protocol_value
case 456: // replace_client_name_value
value.move< ElementPtr > (s.value);
break;
case 151: // "boolean"
case 153: // "boolean"
value.move< bool > (s.value);
break;
case 150: // "floating point"
case 152: // "floating point"
value.move< double > (s.value);
break;
case 149: // "integer"
case 151: // "integer"
value.move< int64_t > (s.value);
break;
case 148: // "constant string"
case 150: // "constant string"
value.move< std::string > (s.value);
break;
@@ -1807,7 +1817,7 @@ namespace isc { namespace dhcp {
375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
405, 406
405, 406, 407, 408
};
return static_cast<token_type> (yytoken_number_[type]);
}
@@ -2052,6 +2062,18 @@ namespace isc { namespace dhcp {
return symbol_type (token::TOKEN_KEYSPACE, l);
}
Dhcp4Parser::symbol_type
Dhcp4Parser::make_MAX_RECONNECT_TRIES (const location_type& l)
{
return symbol_type (token::TOKEN_MAX_RECONNECT_TRIES, l);
}
Dhcp4Parser::symbol_type
Dhcp4Parser::make_RECONNECT_WAIT_TIME (const location_type& l)
{
return symbol_type (token::TOKEN_RECONNECT_WAIT_TIME, l);
}
Dhcp4Parser::symbol_type
Dhcp4Parser::make_VALID_LIFETIME (const location_type& l)
{
@@ -2715,7 +2737,7 @@ namespace isc { namespace dhcp {
#line 14 "dhcp4_parser.yy" // lalr1.cc:377
} } // isc::dhcp
#line 2719 "dhcp4_parser.h" // lalr1.cc:377
#line 2741 "dhcp4_parser.h" // lalr1.cc:377