Database connection failure and retry

Ming-Ching Tiew mingching.tiew at redtone.com
Thu Jun 9 08:46:30 CEST 2005


A little while ago I posted about in my configuration, using unixodbc/freetds,
we noticed that database/network failure causes permanent disability in 
radius server to stop logging and I was given the reply that it is in the 
feature of radius server to retry upon failure.

So there is a discrepancy between what I noticed verses the "supposed to be" 
behaviour.

Upon further investigation I explored into the code, I found this in sql_mysql.c :-

static int sql_fetch_row(SQLSOCK * sqlsocket, SQL_CONFIG *config)
{
        rlm_sql_mysql_sock *mysql_sock = sqlsocket->conn;

        /*
         *  Check pointer before de-referencing it.
         */
        if (!mysql_sock->result) {
                return SQL_DOWN;
        }

        sqlsocket->row = mysql_fetch_row(mysql_sock->result);

        if (sqlsocket->row == NULL) {
                return sql_check_error(mysql_errno(mysql_sock->sock));
        }
        return 0;
}


However the code in sql_unixodbc.c is like this :-


static int sql_fetch_row(SQLSOCK *sqlsocket, SQL_CONFIG *config) {
    rlm_sql_unixodbc_sock *unixodbc_sock = sqlsocket->conn;

    sqlsocket->row = NULL;

    if(SQLFetch(unixodbc_sock->stmt_handle) == SQL_NO_DATA_FOUND)
        return 0;

    /* XXX Check if return suggests we should return error or SQL_DOWN */

    sqlsocket->row = unixodbc_sock->row;
    return 0;
}


There is no checking whatsoever, so unixodbc driver is unable to reconnect 
upon  failure.








More information about the Freeradius-Users mailing list