-
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
Incremental backup: do not error on empty backup #15022
Changes from 6 commits
248f026
c6a9bcd
f109074
eb3d2b8
4364e45
5381d05
b680769
0e85d1d
16585e4
aa2909a
eb20df0
bd2182d
6744449
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 |
---|---|---|
|
@@ -104,8 +104,7 @@ func ChooseBinlogsForIncrementalBackup( | |
// The other thing to validate, is that we can't allow a situation where the backup-GTIDs have entries not covered | ||
// by our binary log's Previous-GTIDs (padded with purged GTIDs). Because that means we can't possibly restore to | ||
// such position. | ||
prevGTIDsUnionPurged := prevGTIDsUnion.Union(purgedGTIDSet) | ||
if !prevGTIDsUnionPurged.Contains(backupFromGTIDSet) { | ||
if prevGTIDsUnionPurged := prevGTIDsUnion.Union(purgedGTIDSet); !prevGTIDsUnionPurged.Contains(backupFromGTIDSet) { | ||
return nil, "", "", vterrors.Errorf(vtrpc.Code_FAILED_PRECONDITION, | ||
"Mismatching GTID entries. Requested backup pos has entries not found in the binary logs, and binary logs have entries not found in the requested backup pos. Neither fully contains the other.\n- Requested pos=%v\n- binlog pos=%v\n- purgedGTIDSet=%v\n- union=%v\n- union purged=%v", | ||
backupFromGTIDSet, previousGTIDsPos.GTIDSet, purgedGTIDSet, prevGTIDsUnion, prevGTIDsUnionPurged) | ||
|
@@ -133,7 +132,16 @@ func ChooseBinlogsForIncrementalBackup( | |
} | ||
return binaryLogsToBackup, incrementalBackupFromGTID, incrementalBackupToGTID, nil | ||
} | ||
return nil, "", "", vterrors.Errorf(vtrpc.Code_FAILED_PRECONDITION, "no binary logs to backup (increment is empty)") | ||
if prevGTIDsUnion.Union(purgedGTIDSet).Equal(backupFromGTIDSet) { | ||
// This means we've iterated over all binary logs, and as it turns out, the backup pos is | ||
// identical to the Previous-GTIDs of the last binary log. But, we also know that we ourselves | ||
// have flushed the binary logs so as to generate the new (now last) binary log. | ||
// Which means, from the Pos of the backup till the time we issued FLUSH BINARY LOGS, there | ||
// were no new GTID entries. The database was completely silent during that period. | ||
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. Slightly more explanative to note in this and similar places that the database performed no writes vs "did nothing" / "was silent" etc. 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. Reworded. |
||
// We have nothing to backup. The backup is empty. | ||
return nil, "", "", nil | ||
} | ||
return nil, "", "", vterrors.Errorf(vtrpc.Code_FAILED_PRECONDITION, "no binary logs to backup. backupFromGTIDSet=%v, prevGTIDsUnion=%v", backupFromGTIDSet.String(), prevGTIDsUnion.String()) | ||
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. It's more accurate to say that there are no new GTIDs to backup as flush logs could have been done N times (along with mysqld restarts etc). Right? Or we could say:
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. Reworded as "cannot find binary logs that cover requested GTID range" |
||
} | ||
|
||
// IsValidIncrementalBakcup determines whether the given manifest can be used to extend a backup | ||
|
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.
Something like
no new data to backup, skipping it
is more informative, IMO.