Change local_metadata.value to MEDIUMBLOB to accomodate long replication positions.

Signed-off-by: deepthi <deepthi@planetscale.com>
This commit is contained in:
deepthi 2019-10-30 12:31:29 -07:00
Родитель 6aeb071877
Коммит 6c6a70a70b
3 изменённых файлов: 7 добавлений и 5 удалений

Просмотреть файл

@ -26,6 +26,7 @@ import (
"golang.org/x/net/context"
"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/sqlescape"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/mysqlctl/backupstorage"
@ -318,8 +319,7 @@ func Restore(ctx context.Context, params RestoreParams) (*BackupManifest, error)
// Add backupTime and restorePosition to LocalMetadata
params.LocalMetadata["RestoredBackupTime"] = manifest.BackupTime
// TODO(deepthi): Uncomment this when the table is fixed to fit replication positions.
//params.LocalMetadata["RestorePosition"] = mysql.EncodePosition(manifest.Position)
params.LocalMetadata["RestorePosition"] = mysql.EncodePosition(manifest.Position)
// Populate local_metadata before starting without --skip-networking,
// so it's there before we start announcing ourselves.

Просмотреть файл

@ -30,7 +30,7 @@ import (
const (
sqlCreateLocalMetadataTable = `CREATE TABLE IF NOT EXISTS _vt.local_metadata (
name VARCHAR(255) NOT NULL,
value VARCHAR(255) NOT NULL,
value MEDIUMBLOB NOT NULL,
PRIMARY KEY (name)
) ENGINE=InnoDB`
sqlCreateShardMetadataTable = `CREATE TABLE IF NOT EXISTS _vt.shard_metadata (
@ -46,6 +46,9 @@ var (
sqlAlterLocalMetadataTable = []string{
`ALTER TABLE _vt.local_metadata ADD COLUMN db_name VARBINARY(255) NOT NULL DEFAULT ''`,
`ALTER TABLE _vt.local_metadata DROP PRIMARY KEY, ADD PRIMARY KEY(name, db_name)`,
// VARCHAR(255) is not long enough to hold replication positions, hence changing to
// MEDIUMBLOB.
`ALTER TABLE _vt.local_metadata CHANGE value value MEDIUMBLOB NOT NULL`,
}
sqlAlterShardMetadataTable = []string{
`ALTER TABLE _vt.shard_metadata ADD COLUMN db_name VARBINARY(255) NOT NULL DEFAULT ''`,

Просмотреть файл

@ -263,8 +263,7 @@ class TestRecovery(unittest.TestCase):
self.assertEqual(metadata['Alias'], 'test_nj-0000062346')
self.assertEqual(metadata['ClusterAlias'], 'recovery_keyspace.0')
self.assertEqual(metadata['DataCenter'], 'test_nj')
# TODO(deepthi): Uncomment this when RestorePosition is fixed.
#self.assertEqual(metadata['RestorePosition'], master_pos)
self.assertEqual(metadata['RestorePosition'], master_pos)
logging.debug('RestoredBackupTime: %s', str(metadata['RestoredBackupTime']))
gotTime = datetime.strptime(metadata['RestoredBackupTime'], '%Y-%m-%dT%H:%M:%SZ')
self.assertEqual(gotTime, expectedTime)