Anope Support > 2.0.x/1.9.x Support

[MySQL] irc2sql anope_server not proper updating?

(1/2) > >>

DJFelipe:
Hey there!

since the 2.X Version i was wondering, why my magIRC always shows servers as offline after a netsplit and reconnect.. So today i was digging around in the File 'irc2sql.cpp' at void 'IRC2SQL::OnNewServer(Server *server)'
Are there parameters missing? I dont see any parsing of the 'online' or 'link_time' values? If i get the code right, only a new server will be flagged as online but after that, it will stay offline forever?


--- Code: ---void IRC2SQL::OnNewServer(Server *server)
{
        query = "INSERT DELAYED INTO `" + prefix + "server` (name, hops, comment, link_time, online, ulined) "
                "VALUES (@name@, @hops@, @comment@, now(), 'Y', @ulined@) "
                "ON DUPLICATE KEY UPDATE name=VALUES(name), hops=VALUES(hops), comment=VALUES(comment), "
                        "link_time=VALUES(link_time), online=VALUES(online), ulined=(ulined)";
        query.SetValue("name", server->GetName());
        query.SetValue("hops", server->GetHops());
        query.SetValue("comment", server->GetDescription());
        query.SetValue("ulined", server->IsULined() ? "Y" : "N");
        this->RunQuery(query);
}
--- End code ---
https://github.com/anope/anope/blob/2.0/modules/extra/stats/irc2sql/irc2sql.cpp#L69


So, as the class 'Server' doesnt have a 'online' flag, i think it will be okay to assume in the query, that the server is now online.. But for the 'link_time' i have no clue...

genius3000:
I'm not very familiar with the stats/irc2sql code or even the use of it but this looks proper. OnNewServer() is called whenever a server is added to Anope's internal handling (e.g., whenever a server connects). In that query, 'online' is set to 'Y', meaning Yes/True and 'link_time' is the output of the MySQL function `now()`.

DJFelipe:
Normally i would expect this behaviour, your right..

So lets have a closer look... The void gets fired and the SQL Query will be setup, it will look like this:

--- Code: ---INSERT DELAYED INTO `anope_server` (name, hops, comment, link_time, online, ulined) "
                "VALUES ('Testserver.Inter.NET', 0, 'No Comment', '2020-10-21 07:00:00', 'Y', 'N') "
        "ON DUPLICATE KEY UPDATE name='Testserver.Inter.NET', hops=0, comment='No Comment', "
                        "link_time='2020-10-21 07:00:00', online=VALUES(online), ulined='N'";
--- End code ---
On the first execution, it will add a new entry into the table and say the Server is online=Y...
But on the further executions, as we have now a duplicate key, the second statement of the query will get handled, 'online' will stay at its default value of 'N' as online never gets parsed (also link_time) so the default value for that column is assumed

So from my point of view, this should fix that issue:

--- Code: ---void IRC2SQL::OnNewServer(Server *server)
{
        query = "INSERT DELAYED INTO `" + prefix + "server` (name, hops, comment, link_time, online, ulined) "
                "VALUES (@name@, @hops@, @comment@, now(), 'Y', @ulined@) "
                "ON DUPLICATE KEY UPDATE name=VALUES(name), hops=VALUES(hops), comment=VALUES(comment), "
                        "link_time=NOW(), online='Y', ulined=(ulined)";
        query.SetValue("name", server->GetName());
        query.SetValue("hops", server->GetHops());
        query.SetValue("comment", server->GetDescription());
        query.SetValue("ulined", server->IsULined() ? "Y" : "N");
        this->RunQuery(query);
}
--- End code ---
Im not 100% sure about the link_time, but online=Y makes definitly sense at that point... The VOID will get fired when a Server connects to the network, so it IS online

Jens Voss:
Sadie committed a fix yesterday.
please checkout the latest git and try again.

DJFelipe:
As i am running a productive environment, i can only try it at saturday night (i dont want to disturb my users :)) Maybe i will find some time to setup a testing environment and check it there...

I guess you mean this changeset? https://github.com/anope/anope/commit/a3c7f716bd256d8b8ead578b1a6bc657f31aec4d

I dont think that this will fix the issue, as Sadie only touched the 'ulined' part... Also online=VALUES(online) will fetch the current value and rewrite it.. So after a netsplit it will be online='N' and will stay 'N' after that query? Please correct me if im wrong...

Navigation

[0] Message Index

[#] Next page

Go to full version