[rtg] yrtg not reconnecting after mysql loss

Bryan Wann bwann-rtg at wann.net
Sat May 3 00:17:30 EDT 2008


On Fri, 2 May 2008, bill fumerola wrote:

> yrtg was done around rtg 7.x, which was before librtg{mysql,pgsql,*}.c
> was introduced, so just because the patch applies doesn't mean that the
> codepath is intended.

That'd explain a few things, such as why the version label is set to 
"0.8.1-yrtg" yet it still uses 0.7-style rtgplot.  (Using Steve Scaffidi's 
yrtg-builder which uses a 2004/11/03 checkout.)

It turns out the librtgmysql.c was a red herring.  After fiddling with it, 
I realized I was producing the same rtgplot after each change.  Looks like 
librtgmysql.c is in CVS at that point, but it's not doing anything.

I think I've got a working solution now.  At first I tried using 
mysql_options() in rtgmysql.c before, after, and before+after 
mysql_real_connect().  It all cases it changed the failure from a 
CR_SERVER_GONE_ERROR(2006) to a CR_IPSOCK_ERROR(2004) and stopped 
buffering results.  Reverting that, I modified rtgsqlbuf.c like you 
suggested.  So far this seems to work, I shut down MySQL for several poll 
cycles and it picked back up after starting.


--- yrtg/src/rtgsqlbuf.c.orig     2008-05-02 22:46:37.000000000  -0500
+++ yrtg/src/rtgsqlbuf.c  2008-05-02 20:09:52.000000000 -0500
@@ -132,6 +132,10 @@
                         debug(LOW, "*** mysql unavailable (%u),  buffering\n",
                             myerrno);

+                        if(mysql_dbconnect(set.dbdb, mysql) != 0)
+                          debug(LOW, "*** unable to reconnect to mysql  (%u)\n",
+                            myerrno);
+
                         /*
                          * if the allocation succeeds: tack a comma back  on the
                          * end of the buffer and resume queueing.

While mysqld was stopped:

*** mysql unavailable (2006), buffering
** Failed: Can't connect to local MySQL server through socket 
'/var/lib/mysql/mysql.sock' (2)Connecting to MySQL database 'rtg' on 
'localhost'...*** unable to reconnect to mysql (2006)


Thanks for your help and input!



Met vriendelijke groet/kind regards,
bryan


More information about the RTG mailing list