-
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
Incremental backup: do not error on empty backup #15022
Conversation
…te MANIFEST file Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #15022 +/- ##
==========================================
+ Coverage 47.64% 47.68% +0.04%
==========================================
Files 1151 1155 +4
Lines 239843 240169 +326
==========================================
+ Hits 114268 114522 +254
- Misses 116975 117045 +70
- Partials 8600 8602 +2 ☔ View full report in Codecov by Sentry. |
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.
LGTM! I only had minor comments and suggestions so will let you address those as you prefer.
go/vt/mysqlctl/backup.go
Outdated
logger.Errorf2(err, "backup is not usable, aborting it") | ||
finishErr = bh.AbortBackup(ctx) | ||
case BackupEmpty: | ||
logger.Infof("backup is empty") |
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.
go/vt/mysqlctl/binlogs_gtid.go
Outdated
// 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Reworded.
go/vt/mysqlctl/binlogs_gtid.go
Outdated
// 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 comment
The 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:
return nil, "", "", vterrors.Errorf(vtrpc.Code_FAILED_PRECONDITION, "no binary logs containing new GTIDs to backup. backupFromGTIDSet=%v, prevGTIDsUnion=%v", backupFromGTIDSet.String(), prevGTIDsUnion.String())
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.
Reworded as "cannot find binary logs that cover requested GTID range"
@@ -204,7 +204,7 @@ func (fe *FileEntry) open(cnf *Mycnf, readOnly bool) (*os.File, error) { | |||
|
|||
// ExecuteBackup runs a backup based on given params. This could be a full or incremental backup. | |||
// The function returns a boolean that indicates if the backup is usable, and an overall error. |
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.
We should update the comment.
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.
Reworded as "The function returns a BackupResult that indicates the usability of the backup"
@@ -233,24 +233,25 @@ func getIncrementalFromPosGTIDSet(incrementalFromPos string) (replication.Mysql5 | |||
// executeIncrementalBackup runs an incremental backup, based on given 'incremental_from_pos', which can be: | |||
// - A valid position | |||
// - "auto", indicating the incremental backup should begin with last successful backup end position. | |||
func (be *BuiltinBackupEngine) executeIncrementalBackup(ctx context.Context, params BackupParams, bh backupstorage.BackupHandle) (bool, error) { | |||
// The function returns a boolean that indicates if the backup is usable, and an overall error. |
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.
This comment is also off now, right?
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.
Reworded
} | ||
return true, nil | ||
return BackupUsable, nil | ||
} | ||
|
||
// executeFullBackup returns a boolean that indicates if the backup is usable, |
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.
Comment off note again.
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.
Reworded
go/vt/mysqlctl/xtrabackupengine.go
Outdated
@@ -168,7 +168,7 @@ func closeFile(wc io.WriteCloser, fileName string, logger logutil.Logger, finalE | |||
|
|||
// ExecuteBackup runs a backup based on given params. This could be a full or incremental backup. | |||
// The function returns a boolean that indicates if the backup is usable, and an overall error. |
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.
Another comment :)
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.
Reworded
go/vt/mysqlctl/xtrabackupengine.go
Outdated
@@ -177,17 +177,17 @@ func (be *XtrabackupEngine) ExecuteBackup(ctx context.Context, params BackupPara | |||
|
|||
// executeFullBackup returns a boolean that indicates if the backup is usable, |
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.
You guess it
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.
lol
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Docs PR: vitessio/website#1668 |
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
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.
Looks good to me!
Description
An incremental backup backs up the delta of binary logs from last known good backup up to the point where the incremental backup is requested. An incremental backup flushes the binary logs and sees what binary log content needs to be backed-up.
It is possible for an incremental backup to be empty. This can happen when the database is sitting idly doing absolutely nothing from the last good backup to the point of incremental backup.
Up till now, this resulted with an error:
vterrors.Errorf(vtrpc.Code_FAILED_PRECONDITION, "no binary logs to backup (increment is empty)")
.But this is an undesired behavior. It is possible for databases to sit idly. If someone were to set up a cronjob running an incremental backup at, say, every
1min
or every5min
, then they'd have to deal with a lot of errors that really are not indicative of anything wrong per se in the database or in the backup process.The decision to error on an empty backup was never formalized and was left as an arbitrary behavior. We now fomalize the behavior for an empty backup:
0
, ie not an error."backup is empty"
in its standard output (wording might change)MANIFEST
or otherwise any files to such backup.s3
) created at the beginning of the process, but it is then removed once the backup is found to be empty. Such cleanup could fail, leaving an empty path with no files.To that effect, this PR:
BackupResult
enum (backup is unusable, is empty, or is usable)Related Issue(s)
Checklist
Deployment Notes