[asterisk-dev] The OLD CDR system and mysql :)

Andrea Spadaccini a.spadaccini at mediatechnologies.it
Sat Mar 31 02:16:46 MST 2007


Ciao Florian,

> > Wouldn't it be a better approach to open the connection only when it's
> > needed? If someone thinks this is a good idea, I can submit a patch to the
> > bug tracker.  
> 
> Rather not. On busy systems this would mean that there are lots of new 
> connection setups and tear-downs toward the mysql server, causing lots 
> of additional work. On quiet systems this would not be a problem, but 
> having one connection open wouldn't either, assuming the reconnection 
> process is correct and efficient.

Well, then we could move to LOG_WARNING the error messages in the switch
statement:

if ((error = mysql_ping(&mysql))) {
            connected = 0;
            records = 0;
            switch (error) {
                case CR_SERVER_GONE_ERROR:
                case CR_SERVER_LOST:
                    ast_log(LOG_ERROR, "cdr_mysql: Server has gone away. Attempting to reconnect.\n");
                    break;
                default:
                    ast_log(LOG_ERROR, "cdr_mysql: Unknown connection error: (%d) %s\n", mysql_errno(&mysql), mysql_error(&mysql));
            }
            retries--;
            if (retries)
                goto db_reconnect;
            else
                ast_log(LOG_ERROR, "cdr_mysql: Retried to connect fives times, giving up.\n");
        }

so that the first two ast_log go to WARNING level and the last one remains on
ERROR level. IMHO a disconnection could be a normal condition in systems with a
low wait_timeout, and I personally don't like that my error.log files are full
of those error messages that are not caused by REAL errors.

What do you think about it?

Note that the switch statement should check for mysql_error(&mysql) return
value, not for mysql_ping() return value. I just filed a bug (#9434) and sent a
patch to fix this.

Have a nice day,

-- 
Dott. Andrea Spadaccini
Multimedia Technologies Institute - MTI S.r.l.


More information about the asterisk-dev mailing list