[Icecast-dev] MySQL Stats

Luca Cireddu sardylan at gmail.com
Tue Aug 6 14:29:52 PDT 2013

Icecast tries to ping MySQL DB every 10 seconds (#define
MYSQLSTATS_DBCHECK_INTERVAL 10) using mysql_ping() native function.
If the DB doesn't answer, it closes the connection calling
mysqlStatsDBClose() to free memory and wait for the next ping.
The next time, it will find the DB connection closed so it tries to
reopen it to have MySQL Stats working again, but there is an increment
of an internal counter.
Icecast tries to "reopen" MySQL connection for a maximum of 3 times, as

During the mysql-down period, all functions related to MySQL are skipped
automatically using a global variable called mysqlstats_enabled.
All statements regarding this variable, including conditional checks and
assignments, are included between mutex lock and unlock, so there isn't
the possibility that the connection is voluntarily closed during other
threads' operations.

After 3 retries, MySQL Stats are definitively disabled, and you have to
restart icecast daemon to get stats working again, but all native
icecast functions continue to work as usual.
It's a temporary solution, but it's working fine.
Another way could be to retry indefinitely, or defining
MYSQLSTATS_DBCHECK_RETRY_MAX to 1000 or some high value.
You can change this value in mysqlstats.h


On 08/06/2013 08:27 PM, Alejandro wrote:
> Lucca, 
> What happend if the DB server is not up?
> Thanks,
> Ale

More information about the Icecast-dev mailing list