Bug #79174 mysqlrpladmin should abort if external script fails
Submitted: 8 Nov 2015 5:17 Modified: 23 Nov 2016 10:42
Reporter: monty solomon Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Utilities Severity:S2 (Serious)
Version:1.5, 1.6 OS:Any
Assigned to: CPU Architecture:Any

[8 Nov 2015 5:17] monty solomon
Description:
According to the documentation, the mysqlrpladmin utility permits the user to specify an external script to execute before and after the switchover and failover commands and if the script returns a value other than 0, the result code is presented in an error message.

The error message is generated as described but mysqlrpladmin continues to process the switchover or failover even if the execution of the script is critical to the process.

How to repeat:
Create a script that returns a non-zero exit status.

Execute a switchover using the mysqlrpladmin utility

mysqlrpladmin switchover --verbose --discover-slaves-login=.mysqlrpladmin.cnf[white-fog] --master=.mysqlrpladmin.cnf[white-fog] --new-master=.mysqlrpladmin.cnf[calm-shape] --demote-master --rpl-user=SUSR_Repl:redacted --log=mysqlrpladmin.log --timeout=5 --exec-before $HOME/test.sh --exec-after $HOME/test.sh

Observe error messages and that mysqlrpladmin continues to process the switchover.

...

# Spawning external script.
# SCRIPT EXECUTED: ['/home/msolomon/test.sh', 'white-fog', '3306', 'calm-shape', '3306']
ERROR: test.sh Script failed. Result = 1
# Blocking writes on master.
# LOCK STRING: FLUSH TABLES WITH READ LOCK

...

#   Executing start on slave white-fog:3306 Ok
# Spawning external script.
# SCRIPT EXECUTED: ['/home/msolomon/test.sh', 'calm-shape', '3306']
ERROR: test.sh Script failed. Result = 1
# Checking slaves for errors.

...

Suggested fix:
Abort without making any changes if before-script fails.

Abort but leave the new master in read-only state if after-script fails.
[23 Nov 2016 10:42] Chiranjeevi Battula
Hello monty solomon,

Thank you for the bug report.
The utility is designed by requirements set forth previous to not abort if an external script fails. The feature has been improved to better capture errors on external script execution.

Thanks,
Chiranjeevi.