#
# The solution is to either lower the 'min' connections,
# or increase lifetime/idle_timeout.
+
+ # Maximum number of times an operation can be retried
+ # if it returns an error which indicates the connection
+ # needs to be restarted. This includes timeouts.
+ max_retries = 5
}
}
#
# The solution is to either lower the "min" connections,
# or increase lifetime/idle_timeout.
+
+ # Maximum number of times an operation can be retried
+ # if it returns an error which indicates the connection
+ # needs to be restarted. This includes timeouts.
+ max_retries = 5
}
# Set to 'yes' to read radius clients from the database ('nas' table)
*/
int fr_connection_pool_get_num(fr_connection_pool_t *pool);
+int fr_connection_pool_get_retries(fr_connection_pool_t *pool);
+
/*
* Pool management
*/
uint32_t spare; //!< Number of spare connections to try.
uint32_t pending; //!< Number of pending open connections.
uint32_t retry_delay; //!< seconds to delay re-open after a failed open.
+ uint32_t max_retries; //!< Maximum number of retries to attempt for any given
+ //!< operation (e.g. query or bind)
uint32_t cleanup_interval; //!< Initial timer for how often we sweep the pool
//!< for free connections. (0 is infinite).
int delay_interval; //!< When we next do a cleanup. Initialized to
{ "cleanup_interval", FR_CONF_OFFSET(PW_TYPE_INTEGER, fr_connection_pool_t, cleanup_interval), "30" },
{ "idle_timeout", FR_CONF_OFFSET(PW_TYPE_INTEGER, fr_connection_pool_t, idle_timeout), "60" },
{ "retry_delay", FR_CONF_OFFSET(PW_TYPE_INTEGER, fr_connection_pool_t, retry_delay), "1" },
+ { "max_retries", FR_CONF_OFFSET(PW_TYPE_INTEGER, fr_connection_pool_t, max_retries), "5" },
{ "spread", FR_CONF_OFFSET(PW_TYPE_BOOLEAN, fr_connection_pool_t, spread), "no" },
CONF_PARSER_TERMINATOR
};
return pool->stats.num;
}
+/** Get the number of times an operation should be retried
+ *
+ * The lower of either the number of available connections or
+ * the configured max_retries.
+ *
+ * @param pool to get the retry count for.
+ * @return the number of times an operation can be retried.
+ */
+int fr_connection_pool_get_retries(fr_connection_pool_t *pool)
+{
+ return (pool->max_retries < pool->stats.num) ? pool->max_retries : pool->stats.num;
+}
/** Get the number of connections currently in the pool
*
* For sanity, for when no connections are viable,
* and we can't make a new one.
*/
- num = retry ? fr_connection_pool_get_num(inst->pool) : 0;
+ num = retry ? fr_connection_pool_get_retries(inst->pool) : 0;
for (i = num; i >= 0; i--) {
#ifdef WITH_SASL
if (sasl && sasl->mech) {
* For sanity, for when no connections are viable,
* and we can't make a new one.
*/
- for (i = fr_connection_pool_get_num(inst->pool); i >= 0; i--) {
+ for (i = fr_connection_pool_get_retries(inst->pool); i >= 0; i--) {
(void) ldap_search_ext((*pconn)->handle, dn, scope, filter, search_attrs,
0, serverctrls, clientctrls, &tv, 0, &msgid);
* For sanity, for when no connections are viable,
* and we can't make a new one.
*/
- for (i = fr_connection_pool_get_num(inst->pool); i >= 0; i--) {
+ for (i = fr_connection_pool_get_retries(inst->pool); i >= 0; i--) {
RDEBUG2("Modifying object with DN \"%s\"", dn);
(void) ldap_modify_ext((*pconn)->handle, dn, mods, NULL, NULL, &msgid);
/*
* inst->pool may be NULL is this function is called by mod_conn_create.
*/
- count = inst->pool ? fr_connection_pool_get_num(inst->pool) : 0;
+ count = inst->pool ? fr_connection_pool_get_retries(inst->pool) : 0;
/*
* Here we try with each of the existing connections, then try to create
/*
* inst->pool may be NULL is this function is called by mod_conn_create.
*/
- count = inst->pool ? fr_connection_pool_get_num(inst->pool) : 0;
+ count = inst->pool ? fr_connection_pool_get_retries(inst->pool) : 0;
/*
* For sanity, for when no connections are viable, and we can't make a new one