How can you shutdown MariaDB 10.4 safely without Data Reliability concerns ?
MariaDB 10.4 has several interesting new features solving database performance and reliability concerns, You can learn more about MariaDB 10.4 new features here . In this post we want to share with you how MariaDB 10.4 has much safer MariaDB Server Shutdown options. So what happens you shutdown ( normal ) MariaDB Server (Master instance ) in a replication infrastructure ? MariaDB Master kills all the client threads in a random order. Technically, MariaDB Server considers binary log dump threads also as client threads so it will also get killed while client threads still exists and this causes a serious Data Reliability risk because data which can be written on the master during normal shutdown won’t be replicated to slave. This unacceptable for several business models which has zero tolerance on data loss. Unfortunately, This happens even when you have deployed MariaDB semi-synchronous replication solution considering more reliable High Availability strategies, How MariaDB 10.4 is solving this problem ?
In MariaDB 10.4 and later you can shutdown MariaDB Server with option WAIT FOR ALL SLAVES – Which means, MariaDB server only kills its binary log dump threads after all client threads have been killed, and it only completes the shutdown after the last binary log has been sent to all connected slaves. You can shutdown MariaDB 10.4 server using either the mysqladmin utility or the SHUTDOWN command, and providing a special option as copied below:
mysqladmin --wait-for-all-slaves shutdown
Shutdown MariaDB 10.4 by providing the WAIT FOR ALL SLAVES option to the command:
SHUTDOWN WAIT FOR ALL SLAVES;
This solution is still not solving concerns related to MariaDB Server 10.4 crash or shutdown from server tools like systemd or sysVinit as we can’t enable this feature by default, So we are expecting more improvements here going forward.
P.S. – If you are using MariaDB 10.3 or/ and before, we strongly recommend to switchover slaves to new master before shutting down the old master. Thanks for spending time in reading this post and your comments are welcome.