CodeSOD: Hard Reboot


Every day in IT, each one of us walks the fine line between "brilliant" and "appalling." We come across things that make our jaws drop, and we’re not sure whether we’re amazed or horrified or both. Here’s a PHP sample that Brett P. was lucky—or unlucky—enough to discover:

This comes from circa 2001, back when there were MySQL stability issues on a server. If in response to the end user’s request the script couldn’t connect to the session database, PHP would shell out to a VB6 .EXE that rebooted the machine. Ta dum! No more connection error!


if (strpos(mysql_error(), "connect to MySQL server on 'localhost' (10061)")) {
    // The MySQL Error: Can't connect to MySQL server on 'localhost' (10061)
    // means that the MySQL database is not running. This is caused by a failed
    // reboot. Since MySQL is not running, it is safe to execute a hard boot.
    echo "Currently rebooting the server. Please try again in two minutes.";
    flush();
    exec("c:\Progra~1\progs\hardboot.exe");
}

That comment block full of flimsy assumptions and unwarranted confidence makes my insides knot up with dread. I’m leaning toward "appalling" on this one. Anyone else?


[Advertisement] Manage IT infrastructure as code across all environments with Puppet. Puppet Enterprise now offers more control and insight, with role-based access control, activity logging and all-new Puppet Apps. Start your free trial today!

http://ift.tt/2q29HE0

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s