MK-SLAVE-DELAY(1)
β¨ mk-slave-delay π β¨
okay so real talk: this is mk-slave-delay(1), a page from the User Contributed Perl Documentation section of your man pages. it's a Maatkit tool. it makes a MySQL slave be late on purpose. yes bestie, intentionally. we're doing chaos with intent. π
πΈ NAME πΈ
mk-slave-delay β Make a MySQL slave server lag behind its master. that's it. that's the whole job. she's a professional latecomer. β°
π¦ SYNOPSIS π¦
Usage: mk-slave-delay [OPTION...] SLAVE-HOST [MASTER-HOST]
so here's the vibe: mk-slave-delay starts and stops a slave server as needed to make it lag behind the master. the SLAVE-HOST and MASTER-HOST use DSN syntax, and values are copied from the SLAVE-HOST to the MASTER-HOST if omitted. so like, if you're lazy (no judgment, we've all been there π
), the master just inherits the slave's settings.
want to hold a slavehost one minute behind its master for ten minutes? say less:
mk-slave-delay --delay 1m --interval 15s --run-time 10m slavehost
periodt. π
π RISKS π
ngl, this section exists to tell you about the potential risks, whether known or unknown, of using this tool. the two main categories of risks are:
- those created by the nature of the tool (e.g. read-only tools vs. read-write tools)
- those created by bugs π
okay so the good news: mk-slave-delay is generally very low-risk. she literally just starts and stops the replication SQL thread. that's the whole thing. but β and this is the tea β this might cause monitoring systems to think the slave is having trouble. so your alerting might start freaking out for no reason. dramatic king behavior from your monitoring stack. π
at the time of this release, we know of no bugs that could cause serious harm to users. slay.
the authoritative source for updated information is always the online issue tracking system. issues that affect this tool will be marked as such. you can see a list of such issues at the following URL: <http://www.maatkit.org/bugs/mk-slave-delay>.
see also BUGS for more info on filing bugs and getting help. iykyk. π
β¨ DESCRIPTION β¨
okay bestie, deep breath, here's how she actually works. π«Ά
mk-slave-delay watches a slave and starts and stops its replication SQL thread as necessary to hold it at least as far behind the master as you request. in practice, it will typically cause the slave to lag between --delay and --delay+--interval behind the master.
she bases the delay on binlog positions in the slave's relay logs by default, so there is no need to connect to the master. iconic. this works well if the IO thread doesn't lag the master much, which is typical in most replication setups; the IO thread lag is usually milliseconds on a fast network. if your IO thread's lag is too large for your purposes though, mk-slave-delay can also connect to the master for information about binlog positions. flexible queen. π
now here's a very specific situation so listen up π’ β if the slave's I/O thread reports that it is waiting for the SQL thread to free some relay log space, mk-slave-delay will automatically connect to the master to find binary log positions. and if --ask-pass and --daemonize are given, it is possible that this could cause it to ask for a password while daemonized. in this case, it exits. so if you think your slave might encounter this condition, you should be sure to either specify --use-master explicitly when daemonizing, or don't specify --ask-pass. protect your peace. π
the SLAVE-HOST and optional MASTER-HOST are both DSNs. see DSN OPTIONS. missing MASTER-HOST values are filled in with values from SLAVE-HOST, so you don't need to specify them in both places. mk-slave-delay reads all normal MySQL option files, such as ~/.my.cnf, so you may not even need to specify username, password and other common options at all. we love a low-effort setup. π
mk-slave-delay tries to exit gracefully by trapping signals such as Ctrl-C. but heads up: you cannot bypass --[no]continue with a trappable signal. that one's a hard no. π«
π PRIVILEGES π
mk-slave-delay requires the following privileges, no negotiations:
PROCESSREPLICATION CLIENTSUPER
that's the entry fee bestie. β¨
π OUTPUT π
if you specify --quiet, there is no output. silence. a mood. π€«
otherwise, the normal output is a status message consisting of a timestamp and information about what mk-slave-delay is doing, and the options are basically:
- starting the slave
- stopping the slave
- or just observing π
very demure, very mindful. π
π OPTIONS π
this tool accepts additional command-line arguments. refer to the SYNOPSIS and usage information for details. okay here's the full lineup, every single one, no skipping:
--ask-passβ Prompt for a password when connecting to MySQL. π--charsetβ short form:-A; type: string. Default character set. okay so if the value isutf8, it sets Perl'sbinmodeonSTDOUTtoutf8, passes themysql_enable_utf8option toDBD::mysql, and runsSET NAMES UTF8after connecting to MySQL. any other value setsbinmodeonSTDOUTwithout theutf8layer, and runsSET NAMESafter connecting to MySQL. π--configβ type: Array. Read this comma-separated list of config files; if specified, this must be the first option on the command line. first. like, before anything else. she's particular. π--[no]continueβ default:yes. Continue replication normally on exit. after exiting, restart the slave's SQL thread with noUNTILcondition, so it will run as usual and catch up to the master. this is enabled by default and works even if you terminatemk-slave-delaywith Control-C. so like, you can't even rage-quit out of this one. π«Ά--daemonizeβ Fork to the background and detach from the shell. POSIX operating systems only. sorry windows girlies. π--defaults-fileβ short form:-F; type: string. Only read mysql options from the given file. you must give an absolute pathname. no shortcuts. π--delayβ type: time; default:1h. How far the slave should lag its master. this is the whole point of the tool, bestie. this is her moment. β°β¨--helpβ Show help and exit. the classic. π--hostβ short form:-h; type: string. Connect to host.--intervalβ type: time; default:1m. How frequentlymk-slave-delayshould check whether the slave needs to be started or stopped. she's checking in on you every minute. clingy but in a cute way. π₯°--logβ type: string. Print all output to this file when daemonized. π--passwordβ short form:-p; type: string. Password to use when connecting. π--pidβ type: string. Create the given PID file when daemonized. the file contains the process ID of the daemonized instance. the PID file is removed when the daemonized instance exits. the program checks for the existence of the PID file when starting; if it exists and the process with the matching PID exists, the program exits. so it's basically a bouncer at the door. πͺ--portβ short form:-P; type: int. Port number to use for connection.--quietβ short form:-q. Don't print informational messages about operation. see OUTPUT for details. π€«--run-timeβ type: time. How longmk-slave-delayshould run before exiting. the default is to run forever. forever ever? forever ever. βΎοΈ--set-varsβ type: string; default:wait_timeout=10000. Set these MySQL variables. immediately after connecting to MySQL, this string will be appended toSETand executed. π οΈ--socketβ short form:-S; type: string. Socket file to use for connection.--use-masterβ Get binlog positions from master, not slave. Don't trust the binlog positions in the slave's relay log. Connect to the master and get binlog positions instead. if you specify this option without giving aMASTER-HOSTon the command line,mk-slave-delayexamines the slave'sSHOW SLAVE STATUSto determine the hostname and port for connecting to the master. π
okay and this part matters: mk-slave-delay uses only the MASTER_HOST and MASTER_PORT values from SHOW SLAVE STATUS for the master connection. it does not use the MASTER_USER value. so if you want to specify a different username for the master than the one you use to connect to the slave, you should specify the MASTER-HOST option explicitly on the command line. no cap. π―
--userβ short form:-u; type: string. User for login if not current user.--versionβ Show version and exit. π·οΈ
π DSN OPTIONS π
these DSN options are used to create a DSN. each option is given like option=value. π«Ά
the options are case-sensitive, so P and p are not the same option. there cannot be whitespace before or after the = and if the value contains whitespace it must be quoted. DSN options are comma-separated. see the maatkit manpage for full details. π
Aβ dsn: charset; copy: yes. Default character set.Dβ dsn: database; copy: yes. Default database.Fβ dsn:mysql_read_default_file; copy: yes. Only read default options from the given file.hβ dsn: host; copy: yes. Connect to host.pβ dsn: password; copy: yes. Password to use when connecting.Pβ dsn: port; copy: yes. Port number to use for connection.Sβ dsn:mysql_socket; copy: yes. Socket file to use for connection.uβ dsn: user; copy: yes. User for login if not current user.
π DOWNLOADING π
you can download Maatkit from Google Code at <http://code.google.com/p/maatkit/>, or you can get any of the tools easily with a command like the following:
wget http://www.maatkit.org/get/toolname
or
wget http://www.maatkit.org/trunk/toolname
where toolname can be replaced with the name (or fragment of a name) of any of the Maatkit tools. once downloaded, they're ready to run; no installation is needed. the first URL gets the latest released version of the tool, and the second gets the latest trunk code from Subversion. so like, released = the polished version, trunk = the girl who just woke up. both valid. π
π ENVIRONMENT π
the environment variable MKDEBUG enables verbose debugging output in all of the Maatkit tools:
MKDEBUG=1 mk-....
literally flip the switch and the tea spills everywhere. π«
π SYSTEM REQUIREMENTS π
you need Perl, DBI, DBD::mysql, and some core packages that ought to be installed in any reasonably new version of Perl. that's the whole list. no crazy dependencies, she's low maintenance. π§
π BUGS π
for a list of known bugs see <http://www.maatkit.org/bugs/mk-slave-delay>.
please use Google Code Issues and Groups to report bugs or request support: <http://code.google.com/p/maatkit/>. you can also join #maatkit on Freenode to discuss Maatkit. come hang out, we don't bite. π«Ά
please include the following when you report, or we literally cannot help you:
- the complete command-line used to reproduce the problem you are seeing
- the version of all MySQL servers involved
- the complete output of the tool when run with
--version - and if possible, debugging output produced by running with the
MKDEBUG=1environment variable
receipts or it didn't happen bestie. πΈ
π COPYRIGHT, LICENSE AND WARRANTY π
this program is copyright 2007-2011 Sergey Zhuravlev and Baron Schwartz. feedback and improvements are welcome. π
THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
this program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2; OR the Perl Artistic License. on UNIX and similar systems, you can issue man perlgpl or man perlartistic to read these licenses. π
you should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
π¦ AUTHOR π¦
Sergey Zhuravlev, Baron Schwartz. β¨ legends.
π«Ά ABOUT MAATKIT π«Ά
okay so real talk β this whole thing? part of Maatkit, which is the toolkit for power users of MySQL. like, if MySQL is the group chat, Maatkit is the folder of perfectly curated reaction pics you keep on standby. π
Maatkit was created by Baron Schwartz, and the primary code contributors are Baron and Daniel Nichter. both of them are employed by Percona. β¨
and the financial support for Maatkit development? primarily provided by Percona and its clients. so like, thank Percona and the clients, bestie. π«Άπ
π VERSION π
this manual page documents:
Ver 1.0.23 Distrib 7540 $Revision: 7477 $
yep. that's the one. iconic, honestly. π
and that's the whole page, bestie β you made it to the end and I'm so proud of you fr fr π
this one came out of the perl v5.42.0 docs, dated 2025-07-24, and it lives under the name MK-SLAVE-DELAY(1). go forth and delay your slaves responsibly, mwah ππΈπ¦
π¦ where this page comes from
- fedora 43: maatkit 7540-39.fc43 Β· GPL-2.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms