I think my question is impossible but I sure I do not know everything.
In my opinion, when mysqld restart, some transaction is not still completed will be rollback on startup. Mysqld use undo log to do it. But is there any way to keep long transactions on restarting mysqld ?
I am using MariaDB Galera with three nodes.
Is there a graceful or safe restart for mysql like for apache httpd?
Basically, it involves some SQL scripting along with whatever operating system scripts or controls you are using to do the server restart.
Just be mindful of how the locking interacts with transactions: http://dev.mysql.com/doc/refman/5.6/en/lock-tables-and-transactions.html