зеркало из https://github.com/github/vitess-gh.git
tabletmanager: Record local metadata values before changing tablet. (#2070)
The prior addition of a call to refreshTablet() before generating local metadata values caused the values to change, since the tablet type has been temporarily changed to RESTORE.
This commit is contained in:
Родитель
86e63ef90d
Коммит
0145dafe33
|
@ -37,6 +37,12 @@ func (agent *ActionAgent) RestoreData(ctx context.Context, logger logutil.Logger
|
|||
}
|
||||
|
||||
func (agent *ActionAgent) restoreDataLocked(ctx context.Context, logger logutil.Logger, deleteBeforeRestore bool) error {
|
||||
// Record local metadata values before we start changing the tablet record.
|
||||
localMetadata, err := agent.getLocalMetadataValues()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// change type to RESTORE (using UpdateTabletFields so it's
|
||||
// always authorized)
|
||||
tablet := agent.Tablet()
|
||||
|
@ -57,10 +63,6 @@ func (agent *ActionAgent) restoreDataLocked(ctx context.Context, logger logutil.
|
|||
// If we're not ok, return an error and the agent will log.Fatalf,
|
||||
// causing the process to be restarted and the restore retried.
|
||||
dir := fmt.Sprintf("%v/%v", tablet.Keyspace, tablet.Shard)
|
||||
localMetadata, err := agent.getLocalMetadataValues()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pos, err := mysqlctl.Restore(ctx, agent.MysqlDaemon, dir, *restoreConcurrency, agent.hookExtraEnv(), localMetadata, logger, deleteBeforeRestore)
|
||||
switch err {
|
||||
case nil:
|
||||
|
|
|
@ -187,6 +187,16 @@ class TestBackup(unittest.TestCase):
|
|||
# check the new slave has the data
|
||||
self._check_data(tablet_replica2, 2, 'replica2 tablet getting data')
|
||||
|
||||
# check that the restored slave has the right local_metadata
|
||||
result = tablet_replica2.mquery('_vt', 'select * from local_metadata')
|
||||
metadata = {}
|
||||
for row in result:
|
||||
metadata[row[0]] = row[1]
|
||||
self.assertEqual(metadata['Alias'], 'test_nj-0000062346')
|
||||
self.assertEqual(metadata['ClusterAlias'], 'test_keyspace.0')
|
||||
self.assertEqual(metadata['DataCenter'], 'test_nj')
|
||||
self.assertEqual(metadata['PromotionRule'], 'neutral')
|
||||
|
||||
# check that the backup shows up in the listing
|
||||
backups = self._list_backups()
|
||||
logging.debug('list of backups: %s', backups)
|
||||
|
|
Загрузка…
Ссылка в новой задаче