-
Notifications
You must be signed in to change notification settings - Fork 500
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
remove temp data in pv for backup #2897
Conversation
Current implementation will delete tempary data even if an error occurs. It's not good for debug but can save more space. |
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.
oh, maybe it's better to clean data only if the upload succeeds.
This is not only for debugging, it's about data safety. For example, the upload process may fail due to network failures, IMO it's better we don't delete local backup data in this case.
After the upload is completed successfully, it's safe to remove local backup data. |
What about restore? |
Maybe we can remove the unpacked datadir? Similiarly can we remove the tar package in lightning restore after it's unpacked? |
I think it's ok to clean temporary files in restoring since the original data is persisted. |
@@ -152,7 +153,9 @@ func (rm *RestoreManager) performRestore(restore *v1alpha1.Restore) error { | |||
klog.Infof("download cluster %s backup %s data success", rm, rm.BackupPath) | |||
|
|||
restoreDataDir := filepath.Dir(restoreDataPath) | |||
defer os.RemoveAll(restoreDataPath) |
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.
Suggest not removing data after restore.
@@ -262,6 +263,8 @@ func (bm *BackupManager) performBackup(backup *v1alpha1.Backup, db *sql.DB) erro | |||
Message: backupErr.Error(), | |||
}) | |||
errs = append(errs, uerr) | |||
// just delete backupFullPath since it will never be used except for debug |
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.
If it's useful for debug, can we keep it just in case?
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.
addressed in df73f02
@@ -166,6 +167,8 @@ func (rm *RestoreManager) performRestore(restore *v1alpha1.Restore) error { | |||
return errorutils.NewAggregate(errs) | |||
} | |||
klog.Infof("unarchive cluster %s backup %s data success", rm, restoreDataPath) | |||
// unarchive succeed, origin archive can be deleted now |
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.
What about keeping the tar, it does not make much difference since we keep the unarchieved files.
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.
addressed in df73f02
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
@DanielZhangQD,Thanks for your review. |
release notes should be accurate and concise for the end-users as they are part of our documentation. please always update the release notes to reflect the latest change and follow the conventions used in our documentation. my suggestion:
|
revised |
/run-all-tests |
/run-all-tests |
@cofyc PTAL again |
@@ -282,6 +283,8 @@ func (bm *BackupManager) performBackup(backup *v1alpha1.Backup, db *sql.DB) erro | |||
return errorutils.NewAggregate(errs) | |||
} | |||
klog.Infof("archive cluster %s backup data %s success", bm, archiveBackupPath) | |||
// archive succeed, origin dir can be deleted safely |
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.
getCommitTsFromMetadata in L305 will fail.
a23fa3b
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
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-1.1 in PR #2922 |
* document how to delete backup * document gc behavior during backup * address comments, add description for pingcap/tidb-operator#2888 (comment) and pingcap/tidb-operator#2897 * address comments * address comments * address comments * Apply suggestions from code review Co-authored-by: Ran <huangran@pingcap.com>
What problem does this PR solve?
Fix #2075
What is changed and how does it work?
Delete temp files in PV (even if an error occurs).
Check List
Tests
Manual apply import/export job, the data can be deleted.
Related changes
Does this PR introduce a user-facing change?: