{"id":370,"date":"2018-07-11T11:44:15","date_gmt":"2018-07-11T09:44:15","guid":{"rendered":"http:\/\/catyellow.net\/blog\/?p=370"},"modified":"2019-01-13T21:56:36","modified_gmt":"2019-01-13T19:56:36","slug":"restart-slave-thread-in-mysql-when-specific-error-occurred","status":"publish","type":"post","link":"https:\/\/catyellow.net\/blog\/?p=370","title":{"rendered":"Restart slave thread in MySQL when specific error occurred"},"content":{"rendered":"<p>On one of slaves I got error:<\/p>\n<pre>write failed: No space left on device (28)<\/pre>\n<p>I also found that slave got 1062 error (&#8220;Duplicate entry&#8221;) and stopped. I cleaned up some free space (old logs). When I tried to restart it with <a href=\"https:\/\/www.percona.com\/doc\/percona-toolkit\/LATEST\/pt-slave-restart.html\" target=\"_blank\" rel=\"noopener\">pt-slave-restart<\/a> then I found that IO_Thread downloads binlogs from master and uses all free space again.<\/p>\n<p>As a workaround &#8211; I decide to start just SQL_Thread, let it process all relay logs and then start IO_Thread again.<\/p>\n<p>This is quick bash <em>oneliner<\/em> I created, which checks replication and if 1062 error exists then does skipping and starting SQL_Thread again.<\/p>\n<p><pre class=\"brush: bash; title: ; notranslate\" title=\"\">while true; do if [[ $(mysql -e \"show slave status\\G\" | grep \"Last_SQL_Errno: 1062\" -c) -gt 0 ]]; then mysql -e \"set global sql_slave_skip_counter=1; start slave sql_thread;\"; fi; done<\/pre><\/p>\n<p>This was enough to get issue fixed.<\/p>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>On one of slaves I got error: write failed: No space left on device (28) I also found that slave got 1062 error (&#8220;Duplicate entry&#8221;) and stopped. I cleaned up some free space (old logs). When I tried to restart it with pt-slave-restart then I found that IO_Thread downloads binlogs from master and uses all [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[3,36],"_links":{"self":[{"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/370"}],"collection":[{"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=370"}],"version-history":[{"count":10,"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/370\/revisions"}],"predecessor-version":[{"id":388,"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/370\/revisions\/388"}],"wp:attachment":[{"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/catyellow.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}