本文整理汇总了Python中mysql.fabric.server.Group.fetch方法的典型用法代码示例。如果您正苦于以下问题:Python Group.fetch方法的具体用法?Python Group.fetch怎么用?Python Group.fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysql.fabric.server.Group
的用法示例。
在下文中一共展示了Group.fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _setup_replication
# 需要导入模块: from mysql.fabric.server import Group [as 别名]
# 或者: from mysql.fabric.server.Group import fetch [as 别名]
def _setup_replication(shard_id, source_group_id, destn_group_id, split_value,
prune_limit, cmd):
"""Setup replication between the source and the destination groups and
ensure that they are in sync.
:param shard_id: The shard ID of the shard that needs to be moved.
:param source_group_id: The group_id of the source shard.
:param destn_group_id: The ID of the group to which the shard needs to
be moved.
:param split_value: Indicates the value at which the range for the
particular shard will be split. Will be set only
for shard split operations.
:param prune_limit: The number of DELETEs that should be
done in one batch.
:param cmd: Indicates the type of re-sharding operation
"""
source_group = Group.fetch(source_group_id)
if source_group is None:
raise _errors.ShardingError(_services_sharding.SHARD_GROUP_NOT_FOUND %
(source_group_id, ))
destination_group = Group.fetch(destn_group_id)
if destination_group is None:
raise _errors.ShardingError(_services_sharding.SHARD_GROUP_NOT_FOUND %
(destn_group_id, ))
master = MySQLServer.fetch(source_group.master)
if master is None:
raise _errors.ShardingError(
_services_sharding.SHARD_GROUP_MASTER_NOT_FOUND)
master.connect()
slave = MySQLServer.fetch(destination_group.master)
if slave is None:
raise _errors.ShardingError(
_services_sharding.SHARD_GROUP_MASTER_NOT_FOUND)
slave.connect()
#Stop and reset any slave that might be running on the slave server.
_utils.set_offline_mode(slave, True) ### TODO: if forced offline_mode
_replication.stop_slave(slave, wait=True)
_replication.reset_slave(slave, clean=True)
#Change the master to the shard group master.
_replication.switch_master(slave, master, master.repl_user, master.repl_pass)
#Start the slave so that syncing of the data begins
_replication.start_slave(slave, wait=True)
_utils.set_offline_mode(slave, False) ### TODO: if forced offline_mode
#Setup sync between the source and the destination groups.
_events.trigger_within_procedure(
SETUP_SYNC,
shard_id,
source_group_id,
destn_group_id,
split_value,
prune_limit,
cmd
)
示例2: start_group_slaves
# 需要导入模块: from mysql.fabric.server import Group [as 别名]
# 或者: from mysql.fabric.server.Group import fetch [as 别名]
def start_group_slaves(master_group_id):
"""Start the slave groups for the given master group. The
method will be used in the events that requires, a group, that
has registered slaves to start them. An example would be
enable shard, enable shard requires that a group start all
the slaves that are registered with it.
:param master_group_id: The master group ID. The ID belongs to the master
whose slaves need to be started.
"""
# Fetch the master group corresponding to the master group
# ID.
master_group = Group.fetch(master_group_id)
if master_group is None:
raise _errors.GroupError(GROUP_REPLICATION_GROUP_NOT_FOUND_ERROR % \
(master_group_id, ))
# Setup replication with masters of the groups registered as master
# groups. master_group.slave_group_ids contains the list of the group
# IDs that are slaves to this master. Iterate through this list and start
# replication with the registered slaves.
for slave_group_id in master_group.slave_group_ids:
slave_group = Group.fetch(slave_group_id)
# Setup replication with the slave group.
try:
setup_group_replication(master_group_id, slave_group.group_id)
except (_errors.GroupError, _errors.DatabaseError) as error:
_LOGGER.warning(
"Error while configuring group replication between "
"(%s) and (%s): (%s).", master_group_id, slave_group.group_id,
error
)
示例3: _lookup
# 需要导入模块: from mysql.fabric.server import Group [as 别名]
# 或者: from mysql.fabric.server.Group import fetch [as 别名]
def _lookup(lookup_arg, key, hint):
"""Given a table name and a key return the servers of the Group where the
shard of this table can be found
:param lookup_arg: table name for "LOCAL" lookups
Shard Mapping ID for "GLOBAL" lookups.
:param key: The key value that needs to be looked up
:param hint: A hint indicates if the query is LOCAL or GLOBAL
:return: The servers of the Group that contains the range in which the
key belongs.
"""
VALID_HINTS = ('LOCAL', 'GLOBAL')
hint = hint.upper()
if hint not in VALID_HINTS:
raise _errors.ShardingError(INVALID_SHARDING_HINT)
group = None
#Perform the lookup for the group contaning the lookup data.
if hint == "GLOBAL":
#Fetch the shard mapping object. In the case of GLOBAL lookups
#the shard mapping ID is passed directly. In the case of "LOCAL"
#lookups it is the table name that is passed.
shard_mapping = ShardMapping.fetch_by_id(lookup_arg)
if shard_mapping is None:
raise _errors.ShardingError(
SHARD_MAPPING_NOT_FOUND % (lookup_arg, )
)
#GLOBAL lookups. There can be only one global group, hence using
#shard_mapping[0] is safe.
group = Group.fetch(shard_mapping[0].global_group)
else:
shard_mapping = ShardMapping.fetch(lookup_arg)
if shard_mapping is None:
raise _errors.ShardingError(TABLE_NAME_NOT_FOUND % (lookup_arg, ))
sharding_specification =\
SHARDING_SPECIFICATION_HANDLER[shard_mapping.type_name].\
lookup(key, shard_mapping.shard_mapping_id, shard_mapping.type_name)
if sharding_specification is None:
raise _errors.ShardingError(INVALID_SHARDING_KEY % (key, ))
shard = Shards.fetch(str(sharding_specification.shard_id))
if shard.state == "DISABLED":
raise _errors.ShardingError(SHARD_NOT_ENABLED)
#group cannot be None since there is a foreign key on the group_id.
#An exception will be thrown nevertheless.
group = Group.fetch(shard.group_id)
if group is None:
raise _errors.ShardingError(SHARD_LOCATION_NOT_FOUND)
ret = []
#An empty list will be returned if the registered group has not
#servers.
for server in group.servers():
ret.append([str(server.uuid), server.address,
group.master == server.uuid])
return ret
示例4: _setup_sync
# 需要导入模块: from mysql.fabric.server import Group [as 别名]
# 或者: from mysql.fabric.server.Group import fetch [as 别名]
def _setup_sync(shard_id, source_group_id, destn_group_id, split_value,
prune_limit, cmd):
"""sync the source and the destination groups.
:param shard_id: The shard ID of the shard that needs to be moved.
:param source_group_id: The group_id of the source shard.
:param destn_group_id: The ID of the group to which the shard needs to
be moved.
:param split_value: Indicates the value at which the range for the
particular shard will be split. Will be set only
for shard split operations.
:param prune_limit: The number of DELETEs that should be
done in one batch.
:param cmd: Indicates the type of re-sharding operation
"""
source_group = Group.fetch(source_group_id)
if source_group is None:
raise _errors.ShardingError(_services_sharding.SHARD_GROUP_NOT_FOUND %
(source_group_id, ))
destination_group = Group.fetch(destn_group_id)
if destination_group is None:
raise _errors.ShardingError(_services_sharding.SHARD_GROUP_NOT_FOUND %
(destn_group_id, ))
master = MySQLServer.fetch(source_group.master)
if master is None:
raise _errors.ShardingError(
_services_sharding.SHARD_GROUP_MASTER_NOT_FOUND)
master.connect()
slave = MySQLServer.fetch(destination_group.master)
if slave is None:
raise _errors.ShardingError(
_services_sharding.SHARD_GROUP_MASTER_NOT_FOUND)
slave.connect()
#Synchronize until the slave catches up with the master.
_replication.synchronize_with_read_only(slave, master)
#Reset replication once the syncing is done.
_replication.stop_slave(slave, wait=True)
_replication.reset_slave(slave, clean=True)
#Trigger changing the mappings for the shard that was copied
_events.trigger_within_procedure(
SETUP_RESHARDING_SWITCH,
shard_id,
source_group_id,
destn_group_id,
split_value,
prune_limit,
cmd
)
示例5: stop_group_slave
# 需要导入模块: from mysql.fabric.server import Group [as 别名]
# 或者: from mysql.fabric.server.Group import fetch [as 别名]
def stop_group_slave(group_master_id, group_slave_id, clear_ref):
"""Stop the slave on the slave group. This utility method is the
completement of the setup_group_replication method and is
used to stop the replication on the slave group. Given a master group ID
and the slave group ID the method stops the slave on the slave
group and updates the references on both the master and the
slave group.
:param group_master_id: The id of the master group.
:param group_slave_id: The id of the slave group.
:param clear_ref: The parameter indicates if the stop_group_slave
needs to clear the references to the group's
slaves. For example when you do a disable
shard the shard group still retains the
references to its slaves, since when enabled
it needs to enable the replication.
"""
master_group = Group.fetch(group_master_id)
slave_group = Group.fetch(group_slave_id)
if master_group is None:
raise _errors.GroupError \
(GROUP_REPLICATION_GROUP_NOT_FOUND_ERROR % (group_master_id, ))
if slave_group is None:
raise _errors.GroupError \
(GROUP_REPLICATION_GROUP_NOT_FOUND_ERROR % (group_slave_id, ))
slave_group_master = MySQLServer.fetch(slave_group.master)
if slave_group_master is None:
raise _errors.GroupError \
(GROUP_REPLICATION_GROUP_MASTER_NOT_FOUND_ERROR %
(slave_group.master, ))
if not server_running(slave_group_master):
#The server is already down. We cannot connect to it to stop
#replication.
return
try:
slave_group_master.connect()
except _errors.DatabaseError:
#Server is not accessible, unable to connect to the server.
return
#Stop replication on the master of the group and clear the references,
#if clear_ref has been set.
_replication.stop_slave(slave_group_master, wait=True)
_replication.reset_slave(slave_group_master, clean=True)
if clear_ref:
slave_group.remove_master_group_id()
master_group.remove_slave_group_id(group_slave_id)
示例6: drop_shard_range_trigger
# 需要导入模块: from mysql.fabric.server import Group [as 别名]
# 或者: from mysql.fabric.server.Group import fetch [as 别名]
def drop_shard_range_trigger(group_id, sharding_type, table_name,
column_name):
"""Drop a trigger on the shard table.
:param group_id: The ID of the group on which the trigger definition
is applied. The trigger is created on the master of
this group.
:param sharding_type: The datatype supported by the shards. Used to
name the trigger.
:param table_name: The name of the table. This is used to name the
trigger being created.
:param column_name: The name of the column in the table being sharded.
This is used to create the name of the trigger.
"""
global_group = Group.fetch(group_id)
master_server = MySQLServer.fetch(global_group.master)
master_server.connect()
db, table = table_name.split(".")
#Drop the INSERT trigger on the sharded table.
trigger_name = db + "." + _TRIGGER_PREFIX_INSERT+table
drop_insert_trigger = _DROP_TRIGGER_DEFN.format(
trigger_name=trigger_name
)
master_server.exec_stmt(drop_insert_trigger)
#Drop the UPDATE trigger on the sharded table.
trigger_name = db + "." + _TRIGGER_PREFIX_UPDATE + table
drop_update_trigger = _DROP_TRIGGER_DEFN.format(
trigger_name=trigger_name
)
master_server.exec_stmt(drop_update_trigger)
示例7: _restore_shard_backup
# 需要导入模块: from mysql.fabric.server import Group [as 别名]
# 或者: from mysql.fabric.server.Group import fetch [as 别名]
def _restore_shard_backup(shard_id, source_group_id, destn_group_id,
backup_image, split_value, prune_limit, cmd):
"""Restore the backup on the destination Group.
:param shard_id: The shard ID of the shard that needs to be moved.
:param source_group_id: The group_id of the source shard.
:param destn_group_id: The ID of the group to which the shard needs to
be moved.
:param backup_image: The destination file that contains the backup
of the source shard.
:param split_value: Indicates the value at which the range for the
particular shard will be split. Will be set only
for shard split operations.
:param prune_limit: The number of DELETEs that should be
done in one batch.
:param cmd: Indicates the type of re-sharding operation
"""
restore_user = _services_utils.read_config_value(
_config.global_config,
'servers',
'restore_user'
)
restore_passwd = _services_utils.read_config_value(
_config.global_config,
'servers',
'restore_password'
)
mysqlclient_binary = _services_utils.read_config_value(
_config.global_config,
'sharding',
'mysqlclient_program'
)
destn_group = Group.fetch(destn_group_id)
if destn_group is None:
raise _errors.ShardingError(_services_sharding.SHARD_GROUP_NOT_FOUND %
(destn_group_id, ))
#Build a backup image that will be used for restoring
bk_img = _backup.BackupImage(backup_image)
for destn_group_server in destn_group.servers():
destn_group_server.connect()
_backup.MySQLDump.restore_fabric_server(
destn_group_server,
restore_user, restore_passwd,
bk_img,
mysqlclient_binary
)
#Setup sync between the source and the destination groups.
_events.trigger_within_procedure(
SETUP_REPLICATION,
shard_id,
source_group_id,
destn_group_id,
split_value,
prune_limit,
cmd
)
示例8: stop_group_slaves
# 需要导入模块: from mysql.fabric.server import Group [as 别名]
# 或者: from mysql.fabric.server.Group import fetch [as 别名]
def stop_group_slaves(master_group_id):
"""Stop the group slaves for the given master group. This will be used
for use cases that required all the slaves replicating from this group to
be stopped. An example use case would be disabling a shard.
:param master_group_id: The master group ID.
"""
master_group = Group.fetch(master_group_id)
if master_group is None:
raise _errors.GroupError \
(GROUP_REPLICATION_GROUP_NOT_FOUND_ERROR % \
(master_group_id, ))
# Stop the replication on all of the registered slaves for the group.
for slave_group_id in master_group.slave_group_ids:
slave_group = Group.fetch(slave_group_id)
# Fetch the Slave Group and the master of the Slave Group
slave_group_master = MySQLServer.fetch(slave_group.master)
if slave_group_master is None:
_LOGGER.warning(
GROUP_REPLICATION_GROUP_MASTER_NOT_FOUND_ERROR % \
(slave_group.master, )
)
continue
if not server_running(slave_group_master):
# The server is already down. we cannot connect to it to stop
# replication.
continue
try:
slave_group_master.connect()
_replication.stop_slave(slave_group_master, wait=True)
# Reset the slave to remove the reference of the master so
# that when the server is used as a slave next it does not
# complaint about having a different master.
_replication.reset_slave(slave_group_master, clean=True)
except _errors.DatabaseError as error:
# Server is not accessible, unable to connect to the server.
_LOGGER.warning(
"Error while unconfiguring group replication between "
"(%s) and (%s): (%s).", master_group_id, slave_group.group_id,
error
)
continue
示例9: _fetch_master_of_group
# 需要导入模块: from mysql.fabric.server import Group [as 别名]
# 或者: from mysql.fabric.server.Group import fetch [as 别名]
def _fetch_master_of_group(group_id):
"""Return a reference to the master of the group.
:param group_id: ID of the group whose master needs to be fetched.
:return: MySQLServer object referring to the group master.
"""
global_group = Group.fetch(group_id)
master_server = MySQLServer.fetch(global_group.master)
master_server.connect()
return master_server
示例10: _backup_source_shard
# 需要导入模块: from mysql.fabric.server import Group [as 别名]
# 或者: from mysql.fabric.server.Group import fetch [as 别名]
def _backup_source_shard(shard_id, source_group_id, destn_group_id,
split_value, prune_limit, cmd, update_only):
"""Backup the source shard.
:param shard_id: The shard ID of the shard that needs to be moved.
:param source_group_id: The group_id of the source shard.
:param destn_group_id: The ID of the group to which the shard needs to
be moved.
:param split_value: Indicates the value at which the range for the
particular shard will be split. Will be set only
for shard split operations.
:param prune_limit: The number of DELETEs that should be
done in one batch.
:param cmd: Indicates the type of re-sharding operation (move, split)
:update_only: Only update the state store and skip provisioning.
"""
backup_user = _services_utils.read_config_value(
_config.global_config,
'servers',
'backup_user'
)
backup_passwd = _services_utils.read_config_value(
_config.global_config,
'servers',
'backup_password'
)
mysqldump_binary = _services_utils.read_config_value(
_config.global_config,
'sharding',
'mysqldump_program'
)
source_group = Group.fetch(source_group_id)
move_source_server = _services_utils.fetch_backup_server(source_group)
#Do the backup of the group hosting the source shard.
backup_image = _backup.MySQLDump.backup(
move_source_server,
backup_user, backup_passwd,
mysqldump_binary
)
#Change the master for the server that is master of the group which hosts
#the destination shard.
_events.trigger_within_procedure(
RESTORE_SHARD_BACKUP,
shard_id,
source_group_id,
destn_group_id,
backup_image.path,
split_value,
prune_limit,
cmd
)
示例11: test_properties
# 需要导入模块: from mysql.fabric.server import Group [as 别名]
# 或者: from mysql.fabric.server.Group import fetch [as 别名]
def test_properties(self):
"""Test group's properties.
"""
group_1 = Group("mysql.com")
Group.add(group_1)
fetched_group_1 = Group.fetch(group_1.group_id)
self.assertEqual(group_1.group_id, "mysql.com")
self.assertEqual(fetched_group_1.group_id, "mysql.com")
self.assertEqual(fetched_group_1.master_defined, None)
group_2 = Group("oracle.com", "First description.")
Group.add(group_2)
fetched_group_2 = Group.fetch(group_2.group_id)
self.assertEqual(group_2.group_id, "oracle.com")
self.assertEqual(fetched_group_2.group_id, "oracle.com")
group_1.description = "New description."
fetched_group_1 = Group.fetch(group_1.group_id)
self.assertEqual(group_1.description, "New description.")
self.assertEqual(fetched_group_1.description, "New description.")
group_1.description = None
fetched_group_1 = Group.fetch(group_1.group_id)
self.assertEqual(group_1.description, None)
self.assertEqual(fetched_group_1.description, None)
group_1.status = Group.INACTIVE
fetched_group_1 = Group.fetch(group_1.group_id)
self.assertEqual(group_1.status, Group.INACTIVE)
self.assertEqual(fetched_group_1.status, Group.INACTIVE)
self.assertEqual(group_1, fetched_group_1)
self.assertEqual(group_2, fetched_group_2)
self.assertNotEqual(group_1, group_2)
set_of_groups = set()
set_of_groups.add(group_1)
set_of_groups.add(group_2)
set_of_groups.add(fetched_group_1)
set_of_groups.add(fetched_group_2)
self.assertEqual(len(set_of_groups), 2)
示例12: _backup_source_shard
# 需要导入模块: from mysql.fabric.server import Group [as 别名]
# 或者: from mysql.fabric.server.Group import fetch [as 别名]
def _backup_source_shard(shard_id, source_group_id, destn_group_id,
mysqldump_binary, mysqlclient_binary, split_value,
config_file, prune_limit, cmd, update_only):
"""Backup the source shard.
:param shard_id: The shard ID of the shard that needs to be moved.
:param source_group_id: The group_id of the source shard.
:param destn_group_id: The ID of the group to which the shard needs to
be moved.
:param mysqldump_binary: The fully qualified mysqldump binary.
:param mysqlclient_binary: The fully qualified mysql client binary.
:param split_value: Indicates the value at which the range for the
particular shard will be split. Will be set only
for shard split operations.
:param config_file: The complete path to the fabric configuration file.
:param prune_limit: The number of DELETEs that should be
done in one batch.
:param cmd: Indicates the type of re-sharding operation (move, split)
:update_only: Only update the state store and skip provisioning.
"""
source_group = Group.fetch(source_group_id)
move_source_server = _services_utils.fetch_backup_server(source_group)
#Do the backup of the group hosting the source shard.
backup_image = _backup.MySQLDump.backup(
move_source_server,
config_file,
mysqldump_binary
)
#Change the master for the server that is master of the group which hosts
#the destination shard.
_events.trigger_within_procedure(
RESTORE_SHARD_BACKUP,
shard_id,
source_group_id,
destn_group_id,
mysqlclient_binary,
backup_image.path,
split_value,
config_file,
prune_limit,
cmd
)
示例13: _restore_shard_backup
# 需要导入模块: from mysql.fabric.server import Group [as 别名]
# 或者: from mysql.fabric.server.Group import fetch [as 别名]
def _restore_shard_backup(shard_id, source_group_id, destn_group_id,
mysqlclient_binary, backup_image,
split_value, config_file, cmd):
"""Restore the backup on the destination Group.
:param shard_id: The shard ID of the shard that needs to be moved.
:param source_group_id: The group_id of the source shard.
:param destn_group_id: The ID of the group to which the shard needs to
be moved.
:param mysqlclient_binary: The fully qualified mysqlclient binary.
:param backup_image: The destination file that contains the backup
of the source shard.
:param split_value: Indicates the value at which the range for the
particular shard will be split. Will be set only
for shard split operations.
:param config_file: The complete path to the fabric configuration file.
:param cmd: Indicates the type of re-sharding operation
"""
destn_group = Group.fetch(destn_group_id)
if destn_group is None:
raise _errors.ShardingError(_services_sharding.SHARD_GROUP_NOT_FOUND %
(destn_group_id, ))
#Build a backup image that will be used for restoring
bk_img = _backup.BackupImage(backup_image)
for destn_group_server in destn_group.servers():
destn_group_server.connect()
_backup.MySQLDump.restore_fabric_server(
destn_group_server,
bk_img,
config_file,
mysqlclient_binary
)
#Setup sync between the source and the destination groups.
_events.trigger_within_procedure(
SETUP_MOVE_SYNC,
shard_id,
source_group_id,
destn_group_id,
split_value,
cmd
)
示例14: add_shard_range_trigger
# 需要导入模块: from mysql.fabric.server import Group [as 别名]
# 或者: from mysql.fabric.server.Group import fetch [as 别名]
def add_shard_range_trigger(group_id, sharding_type, table_name,
column_name):
"""Add a trigger on the shard table to ensure that values
inserted fall within the valid shard ranges.
:param group_id: The ID of the group on which the trigger definition
is applied. The trigger is created on the master of
this group.
:param sharding_type: The datatype supported by the shards. Used to
name the trigger.
:param table_name: The name of the table. This is used to name the
trigger being created.
:param column_name: The name of the column in the table being sharded.
This is used to create the name of the trigger.
"""
global_group = Group.fetch(group_id)
master_server = MySQLServer.fetch(global_group.master)
master_server.connect()
#Create an INSERT trigger on the sharded table.
db, table = table_name.split(".")
trigger_tmpl = _TRIGGER_DEFN[sharding_type]
trigger_name = db + "." + _TRIGGER_PREFIX_INSERT + table
create_insert_trigger = trigger_tmpl.format(
trigger_name=trigger_name,
operation="INSERT",
table_name=table_name,
column_name="NEW"+"."+column_name
)
master_server.exec_stmt(create_insert_trigger)
#Create an UPDATE trigger on the sharded table.
trigger_tmpl = _TRIGGER_DEFN[sharding_type]
trigger_name = db + "." + _TRIGGER_PREFIX_UPDATE + table
create_update_trigger =trigger_tmpl.format(
trigger_name=trigger_name,
operation="UPDATE",
table_name=table_name,
column_name="NEW"+"."+column_name
)
master_server.exec_stmt(create_update_trigger)
示例15: _setup_shard_switch_move
# 需要导入模块: from mysql.fabric.server import Group [as 别名]
# 或者: from mysql.fabric.server.Group import fetch [as 别名]
def _setup_shard_switch_move(shard_id, source_group_id, destination_group_id,
update_only):
"""Setup the moved shard to map to the new group.
:param shard_id: The shard ID of the shard that needs to be moved.
:param source_group_id: The group_id of the source shard.
:param destination_group_id: The ID of the group to which the shard
needs to be moved.
:update_only: Only update the state store and skip provisioning.
"""
#Fetch the Range sharding specification. When we start implementing
#heterogenous sharding schemes, we need to find out the type of
#sharding scheme and we should use that to find out the sharding
#implementation.
_, source_shard, _, shard_mapping_defn = \
_services_sharding._verify_and_fetch_shard(shard_id)
#Setup replication between the shard group and the global group.
_group_replication.setup_group_replication \
(shard_mapping_defn[2], destination_group_id)
#set the shard to point to the new group.
source_shard.group_id = destination_group_id
#Stop the replication between the global server and the original
#group associated with the shard.
_group_replication.stop_group_slave\
(shard_mapping_defn[2], source_group_id, True)
#Reset the read only flag on the source server.
source_group = Group.fetch(source_group_id)
if source_group is None:
raise _errors.ShardingError(_services_sharding.SHARD_GROUP_NOT_FOUND %
(source_group_id, ))
master = MySQLServer.fetch(source_group.master)
if master is None:
raise _errors.ShardingError(
_services_sharding.SHARD_GROUP_MASTER_NOT_FOUND)
if not update_only:
master.connect()
master.read_only = False