-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Point in time recovery and restore: assume (and validate) MySQL56 flavor in position arguments #15599
Point in time recovery and restore: assume (and validate) MySQL56 flavor in position arguments #15599
Changes from 5 commits
629623a
d3e143c
fff521f
8ee1cf6
a88dd20
043deca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,3 +153,40 @@ func TestMysql56ParseGTID(t *testing.T) { | |
require.NoError(t, err, "unexpected error: %v", err) | ||
assert.Equal(t, want, got, "(&mysql56{}).ParseGTID(%#v) = %#v, want %#v", input, got, want) | ||
} | ||
|
||
func TestDecodePositionMySQL56(t *testing.T) { | ||
{ | ||
pos, gtidSet, err := DecodePositionMySQL56("") | ||
assert.NoError(t, err) | ||
assert.True(t, pos.IsZero()) | ||
assert.Nil(t, gtidSet) | ||
} | ||
{ | ||
pos, gtidSet, err := DecodePositionMySQL56("MySQL56/16b1039f-22b6-11ed-b765-0a43f95f28a3:1-615") | ||
assert.NoError(t, err) | ||
assert.False(t, pos.IsZero()) | ||
assert.NotNil(t, gtidSet) | ||
} | ||
{ | ||
pos, gtidSet, err := DecodePositionMySQL56("16b1039f-22b6-11ed-b765-0a43f95f28a3:1-615") | ||
assert.NoError(t, err) | ||
assert.False(t, pos.IsZero()) | ||
assert.NotNil(t, gtidSet) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly here, it will be more robust to assert on the actual result versus only asserting that it is not nil. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. No need for |
||
} | ||
{ | ||
_, _, err := DecodePositionMySQL56("q-22b6-11ed-b765-0a43f95f28a3:1-615") | ||
assert.Error(t, err) | ||
} | ||
{ | ||
_, _, err := DecodePositionMySQL56("16b1039f-22b6-11ed-b765-0a43f95f28a3") | ||
assert.Error(t, err) | ||
} | ||
{ | ||
_, _, err := DecodePositionMySQL56("FilePos/mysql-bin.000001:234") | ||
assert.Error(t, err) | ||
} | ||
{ | ||
_, _, err := DecodePositionMySQL56("mysql-bin.000001:234") | ||
assert.Error(t, err) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -223,18 +223,11 @@ func (be *BuiltinBackupEngine) ExecuteBackup(ctx context.Context, params BackupP | |
|
||
// getIncrementalFromPosGTIDSet turns the given string into a valid Mysql56GTIDSet | ||
func getIncrementalFromPosGTIDSet(incrementalFromPos string) (replication.Mysql56GTIDSet, error) { | ||
pos, err := replication.DecodePositionDefaultFlavor(incrementalFromPos, replication.Mysql56FlavorID) | ||
_, gtidSet, err := replication.DecodePositionMySQL56(incrementalFromPos) | ||
if err != nil { | ||
return nil, vterrors.Wrapf(err, "cannot decode position in incremental backup: %v", incrementalFromPos) | ||
} | ||
if !pos.MatchesFlavor(replication.Mysql56FlavorID) { | ||
return nil, vterrors.Errorf(vtrpc.Code_FAILED_PRECONDITION, "incremental backup only supports MySQL GTID positions. Got: %v", incrementalFromPos) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO it would be nice to move this wording to the error above so that it's clear that we don't support other flavors. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is likewise an intentional design: we There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, but we lose the wording which notes that MySQL format is the only one supported. That was my point. I guess it's implicit in this wording, so not a huge deal. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't lose the wording. The error above will have both |
||
} | ||
ifPosGTIDSet, ok := pos.GTIDSet.(replication.Mysql56GTIDSet) | ||
if !ok { | ||
return nil, vterrors.Errorf(vtrpc.Code_FAILED_PRECONDITION, "cannot get MySQL GTID value: %v", pos) | ||
} | ||
return ifPosGTIDSet, nil | ||
return gtidSet, nil | ||
} | ||
|
||
// executeIncrementalBackup runs an incremental backup, based on given 'incremental_from_pos', which can be: | ||
|
@@ -269,7 +262,7 @@ func (be *BuiltinBackupEngine) executeIncrementalBackup(ctx context.Context, par | |
params.Logger.Infof("auto evaluated incremental_from_pos: %s", params.IncrementalFromPos) | ||
} | ||
|
||
if _, err := replication.DecodePositionDefaultFlavor(params.IncrementalFromPos, replication.Mysql56FlavorID); err != nil { | ||
if _, _, err := replication.DecodePositionMySQL56(params.IncrementalFromPos); err != nil { | ||
// This does not seem to be a valid position. Maybe it's a backup name? | ||
backupName := params.IncrementalFromPos | ||
pos, err := findBackupPosition(ctx, params, backupName) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it worth asserting that the provided gtidSet is not being mangled in any way, and makes it here intact?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done