MXS-1639 Run user-given sql commands during promotion, demotion and rejoin

The sql queries are given in two text files, defined by options promotion_sql_file
and demotion_sql_file. The files must exist when monitor starts. The files are read
line by line, ignoring empty lines and lines starting with '#'. All other lines
are sent to the server being promoted, demoted or rejoined. Any error in opening
a file, reading it or executing the contents will cause the entire operation to
fail.

The filed defined in demotion_sql_file is also ran when rejoining a server. This
is to ensure a previously failed master is "demoted" properly when it joins the
cluster.
This commit is contained in:
Esa Korhonen
2018-04-18 16:00:22 +03:00
parent 474736584b
commit 739edcbe22
2 changed files with 143 additions and 20 deletions

View File

@ -77,6 +77,8 @@ typedef struct
replicating from the wrong master. */
int n_excluded; /**< Number of excluded servers */
MXS_MONITORED_SERVER** excluded_servers; /**< Servers banned for master promotion during auto-failover. */
const char* promote_sql_file; /**< File with sql commands which are ran to a server being promoted. */
const char* demote_sql_file; /**< File with sql commands which are ran to a server being demoted. */
MXS_MONITOR* monitor;
} MYSQL_MONITOR;