Bug #72931 mysqlfabric group destroy --force does not work, Error in _destroy_group.
Submitted: 10 Jun 2014 9:18 Modified: 10 Sep 2014 0:35
Reporter: Shahriyar Rzayev (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Fabric Severity:S3 (Non-critical)
Version:1.4.3 OS:Linux (CentOS 6.5)
Assigned to: CPU Architecture:Any

[10 Jun 2014 9:18] Shahriyar Rzayev
Description:
Tried to destroy group in Fabric.
Here is information:

[root@fabricsrv ~]# mysqlfabric group lookup_servers my_group
Command :
{ success     = True
  return      = [{'status': 'FAULTY', 'server_uuid': '37246eb6-ebc8-11e3-845b-080027e3e8d2', 'mode': 'READ_WRITE', 'weight': 1.0, 'address': '192.168.1.88:3306'}, {'status': 'FAULTY', 'server_uuid': '75c5356e-ebc7-11e3-8456-08002738050e', 'mode': 'READ_WRITE', 'weight': 1.0, 'address': '192.168.1.77:3306'}]
  activities  = 
}

[root@fabricsrv ~]# mysqlfabric group destroy my_group
Procedure :
{ uuid        = 841d9466-fd27-46f4-8976-f698570f03a7,
  finished    = True,
  success     = False,
  return      = GroupError: Group (my_group) is not empty.,
  activities  = 
}

As documentation states i can use --force option to force removing non-empty group:
"
http://dev.mysql.com/doc/mysql-utilities/1.4/en/fabric-quick-start-replication.html

 It is also possible to force removal of a nonempty group by specifying the parameter --force. This command removes all servers from my_group and removes the group.

shell> mysqlfabric group destroy my_group --force"

Usage:

[root@fabricsrv ~]# mysqlfabric group destroy my_group --force
Procedure :
{ uuid        = 850e8e72-e965-4aa8-87b3-77464cb47589,
  finished    = True,
  success     = False,
  return      = DatabaseError: ("Command (DELETE FROM servers WHERE server_uuid = %s, ('37246eb6-ebc8-11e3-845b-080027e3e8d2',)) failed: 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`fabric`.`groups`, CONSTRAINT `fk_master_uid_servers` FOREIGN KEY (`master_uuid`) REFERENCES `servers` (`server_uuid`))", 1451),
  activities  = 
}

And from mysqlfabric manage start output:

[DEBUG] 1402391642.178269 - Executor-4 - _destroy_group failed, executing compensation
[DEBUG] 1402391642.178416 - Executor-4 - Error in _destroy_group.
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/mysql/fabric/executor.py", line 378, in execute
    self.__result = self.__action(*self.__args, **self.__kwargs)
  File "/usr/lib/python2.6/site-packages/mysql/fabric/events.py", line 80, in wrapped
    return wrapped.function(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/mysql/fabric/services/server.py", line 566, in _destroy_group
    _server.MySQLServer.remove(server)
  File "/usr/lib/python2.6/site-packages/mysql/fabric/persistence.py", line 132, in _wrap
    return original(*args, **kwrds)
  File "/usr/lib/python2.6/site-packages/mysql/fabric/server.py", line 1342, in remove
    MySQLServer.REMOVE_SERVER, {"params": (str(server.uuid), )}
  File "/usr/lib/python2.6/site-packages/mysql/fabric/persistence.py", line 512, in exec_stmt
    self.__cnx, stmt_str, options
  File "/usr/lib/python2.6/site-packages/mysql/fabric/server_utils.py", line 151, in exec_mysql_stmt
    error.errno)
DatabaseError: ("Command (DELETE FROM servers WHERE server_uuid = %s, ('37246eb6-ebc8-11e3-845b-080027e3e8d2',)) failed: 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`fabric`.`groups`, CONSTRAINT `fk_master_uid_servers` FOREIGN KEY (`master_uuid`) REFERENCES `servers` (`server_uuid`))", 1451)
[DEBUG] 1402391642.178743 - Executor-4 - Statement (ROLLBACK, Params(()).
[DEBUG] 1402391642.182778 - Executor-4 - Complete job (850e8e72-e965-4aa8-87b3-77464cb47589, 00dbab06-209e-4bde-9229-4fd19d7fba31, mysql.fabric.services.server._destroy_group, Error).
[DEBUG] 1402391642.183131 - Executor-4 - Statement (DELETE FROM checkpoints WHERE proc_uuid = %s, Params(('850e8e72-e965-4aa8-87b3-77464cb47589',)).
[DEBUG] 1402391642.187257 - Executor-4 - Complete procedure (850e8e72-e965-4aa8-87b3-77464cb47589).
[DEBUG] 1402391642.187493 - XML-RPC-Session-1 - Finished command (group, destroy).
[DEBUG] 1402391642.187855 - XML-RPC-Session-1 - Statement (INSERT INTO log (subject, reported, reporter, message, category, type) VALUES(%s, %s, %s, %s, %s, %s), Params(('group.destroy', datetime.datetime(2014, 6, 10, 9, 14, 2), 'mysql.fabric.command', 'Finished command (group, destroy).', 1, 2)).

How to repeat:
All steps provided in Description section.

Suggested fix:
No idea.
[16 Jun 2014 9:18] Mats Kindahl
Thank you for the bug report. Since there is a simple workaround available (just remove the servers from the group before removing the group) and the --force option is not a significant functionality, this was set to serverity 3.
[16 Jun 2014 9:34] Mats Kindahl
Thank you for the bug report. Verified as described.
[10 Sep 2014 0:35] Philip Olson
Fixed as of the upcoming MySQL Utilities/Fabric 1.5.2 release, and here's the changelog entry:

The "--force" option was removed from the "mysqlfabric" utility. It was
removed to help alleviate confusion about its purpose. Its functionality
was replaced by clearer status messages that are always printed out.

Thank you for the bug report.