Bug #71766 mysqlfabric group destroy command failure
Submitted: 19 Feb 2014 0:06 Modified: 11 Mar 2014 6:39
Reporter: Andres Eduardo Sanchez Rodriguez Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Fabric Severity:S2 (Serious)
Version:1.4.0 OS:Linux (2.6.39-200.24.1.el6uek.x86_64)
Assigned to: Alfranio Tavares Correia Junior CPU Architecture:Any

[19 Feb 2014 0:06] Andres Eduardo Sanchez Rodriguez
Description:
When tried to destroy a group, right after removing all servers, observed following error (force option doesnt work either):

mysqlfabric group destroy my_group1 FORCE

Procedure :
{ uuid        = f600e224-f2dc-4051-93a6-f4e0d3541e97,
  finished    = True,
  success     = False,
  return      = DatabaseError: ("Command (DELETE FROM groups WHERE group_id = %s, ('my_group1',)) failed: 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`fabric`.`shards`, CONSTRAINT `fk_shards_group_id` FOREIGN KEY (`group_id`) REFERENCES `groups` (`group_id`))", 1451),
  activities  = 
}

~                                                                                                                                           
~        

How to repeat:
Steps:

1)Create an HA group containing 3 servers.
bash-4.1$ mysqlfabric group check_group_availability my_group1
Command :
{ success     = True
  return      = {'857026ae-98f6-11e3-a84e-00144f0f7e1e': {'is_master': True, 'status': 'PRIMARY', 'is_alive': True, 'threads': {}}, '84753261-98f6-11e3-a84e-00144f0f7e1e': {'is_master': False, 'status': 'SECONDARY', 'is_alive': True, 'threads': {}}, '8a075de9-98f6-11e3-a84e-00144f0f7e1e': {'is_master': False, 'status': 'SECONDARY', 'is_alive': True, 'threads': {}}}
  activities  = 
}

2)Demote the group and remove all servers: 
-bash-4.1$ mysqlfabric group demote my_group1
Procedure :
{ uuid        = bed929b7-f7c2-489e-9824-bed66789f870,
  finished    = True,
  success     = True,
  return      = True,
  activities  = 
}

-bash-4.1$ mysqlfabric group remove my_group1 857026ae-98f6-11e3-a84e-00144f0f7e1e
Procedure :
{ uuid        = 85aadc74-8d11-4996-8825-9b6b0581faa5,
  finished    = True,
  success     = True,
  return      = True,
  activities  = 
}
-bash-4.1$ mysqlfabric group remove my_group1 84753261-98f6-11e3-a84e-00144f0f7e1e
Procedure :
{ uuid        = 49d6e9c6-d783-44f0-8504-07eefa596efc,
  finished    = True,
  success     = True,
  return      = True,
  activities  = 
}
-bash-4.1$ mysqlfabric group remove my_group1 8a075de9-98f6-11e3-a84e-00144f0f7e1e
Procedure :
{ uuid        = c61900d8-f9b0-4a9a-b035-7168e43f0d78,
  finished    = True,
  success     = True,
  return      = True,
  activities  = 
}

3)After this try to destroy group:
-bash-4.1$ mysqlfabric group destroy my_group1
Procedure :
{ uuid        = 09ea87a2-8255-4856-bd84-d0be4fc25975,
  finished    = True,
  success     = False,
  return      = DatabaseError: ("Command (DELETE FROM groups WHERE group_id = %s, ('my_group1',)) failed: 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`fabric`.`shards`, CONSTRAINT `fk_shards_group_id` FOREIGN KEY (`group_id`) REFERENCES `groups` (`group_id`))", 1451),
  activities  = 
}
-bash-4.1$ mysqlfabric group destroy my_group1 FORCE
Procedure :
{ uuid        = f600e224-f2dc-4051-93a6-f4e0d3541e97,
  finished    = True,
  success     = False,
  return      = DatabaseError: ("Command (DELETE FROM groups WHERE group_id = %s, ('my_group1',)) failed: 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`fabric`.`shards`, CONSTRAINT `fk_shards_group_id` FOREIGN KEY (`group_id`) REFERENCES `groups` (`group_id`))", 1451),
  activities  = 
}
[19 Feb 2014 0:19] Andres Eduardo Sanchez Rodriguez
Forgot to mention that for out setup we have 3 group plus global group, and Shards have also been created, of Range type.
[11 Mar 2014 6:39] Philip Olson
Fixed as of the upcoming MySQL for Utilities 1.4.2 release, and here's the changelog entry:

With Fabric, attempting to destroy a group when the group was used in the
shard sub-system would output an unfriendly and unclear error. Fabric now
checks if the group is used in the shard sub-system before trying to
destroy (remove) it, and a clearer error is emitted if it is in use.

Thank you for the bug report.