Re: Best practices for restarting MySQL
Posted by: Rick James
Date: July 02, 2014 07:58PM

Make your application more robust. You have given one example of how MySQL could "go away"; there are many others. Solve them all, at the same time:

* Check for errors after every operation.

* Use InnoDB, not MyISAM.

* Don't turn on auto-reconnect; instead follow the same code as you have for recovering from Deadlocks and other transaction 'errors'. (That is restart the transaction, after reconnecting if necessary.)

* Have some kind of "timeout" in your application -- in the case where it cannot recover or gets in a loop.

* For graceful shutdowns, use SET readonly=1 (and do _not_ connect as 'root'). This prevents writes -- by providing an error to the INSERT/UPDATE/etc statement.

* For graceful shutdowns, use SET max_connections=1. This will give errors for new connections and "reconnect" attempts by the application.

* etc.

Options: ReplyQuote


Subject
Written By
Posted
Re: Best practices for restarting MySQL
July 02, 2014 07:58PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.