Skip to content
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

[Backup]Support content, exclude and whole database in backup #5314

Merged
merged 3 commits into from
Jan 31, 2021

Conversation

EmmyMiao87
Copy link
Contributor

Proposed changes

This PR support following functions:

  1. Support content properties in backup stmt. It means user can backup only metadata or meta+data which use content [METADATA_ONLY| ALL]attribute to distinguish.
  2. Support exclude some tables in backup and restore stmt. This means that some very large and unimportant tables can be excluded when the entire database is backed up.
  3. Support backup and restore whole database instead of declaring each table name in the backup and restore statement.

The backup and restore api has changed as following:

BACKUP SNAPSHOT [db_name].{snapshot_name}
TO 'repo_name'
[ON|EXCLUDE (
    'table_name' [partition (p1,...)]
)]
[properties (
    "content" = "metadata_only|all"
)]

RESTORE SNAPSHOT [db_name].{snapshot_name}
TO 'repo_name'
[EXCLUDE|ON (
    'table_name' [partition (p1,...)]
)]
[properties (
)]

Types of changes

What types of changes does your code introduce to Doris?
Put an x in the boxes that apply

  • [] Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • [] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [] Documentation Update (if none of the other choices apply)
  • [] Code refactor (Modify the code structure, format the code, etc...)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • [] I have created an issue on (Fix Backup and Restore support view and external table #5298 ) and described the bug/feature there in detail
  • Compiling and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • [TODO] If these changes need document changes, I have updated the document
  • [] Any dependent changes have been merged

Further comments

I will continue to update the documentation, please review my code first.

miaoling01 and others added 2 commits January 28, 2021 18:53
Change-Id: Ib1b7649a0657d4295d1b6f23b06d4b6de12efdea
@EmmyMiao87 EmmyMiao87 added area/backup Issues of PRS related to backup and restore kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API api-review Categorizes an issue or PR as actively needing an API review. labels Jan 28, 2021
@morningman morningman changed the title Support content, exclude and whole database in backup [Backup]Support content, exclude and whole database in backup Jan 28, 2021
AbstractBackupTableRefClause abstractBackupTableRefClause = stmt.getAbstractBackupTableRefClause();
if (abstractBackupTableRefClause == null) {
tableNames = db.getTableNamesWithLock();
} else if (abstractBackupTableRefClause != null && abstractBackupTableRefClause.isExclude()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} else if (abstractBackupTableRefClause != null && abstractBackupTableRefClause.isExclude()) {
} else if (abstractBackupTableRefClause.isExclude()) {

} else if (abstractBackupTableRefClause != null && abstractBackupTableRefClause.isExclude()) {
tableNames = db.getTableNamesWithLock();
for (TableRef tableRef : abstractBackupTableRefClause.getTableRefList()) {
tableNames.remove(tableRef.getName().getTbl());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to check if there "excluded" tables exist in database?

eg:

Suggested change
tableNames.remove(tableRef.getName().getTbl());
if (!tableNames.remove(tableRef.getName().getTbl())) {
throw exception()
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can be checked but it is not necessary to report an error.Just write a log.

}
}
List<TableRef> tblRefs = Lists.newArrayList();
if (tableNames.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There may be no table in database at all, and in this case, the tableNames is empty, and abstractBackupTableRefClause is null. So NPE will thrown.

@@ -204,6 +278,7 @@ public String getOrginNameByAlias(String alias) {
public String database;
@SerializedName("backup_time")
public long backupTime;
public BackupContent content;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need @SerializedName?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it will be serialized by default, but some serialized names and attribute names are different.

@morningman morningman self-assigned this Jan 28, 2021
Copy link
Contributor

@morningman morningman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@morningman morningman added the approved Indicates a PR has been approved by one committer. label Jan 30, 2021
@morningman morningman merged commit bb7ba00 into apache:master Jan 31, 2021
@yangzhg yangzhg mentioned this pull request Feb 9, 2021
EmmyMiao87 added a commit to EmmyMiao87/incubator-doris that referenced this pull request Apr 21, 2021
…#5314)

This PR support following functions:
1. Support content properties in backup stmt. It means user can backup only metadata or
meta+data which use content [METADATA_ONLY| ALL]attribute to distinguish.
2. Support exclude some tables in backup and restore stmt. This means that some
very large and unimportant tables can be excluded when the entire database is backed up.
3. Support backup and restore whole database instead of declaring each table name
in the backup and restore statement.

The backup and restore api has changed as following:
```
BACKUP SNAPSHOT [db_name].{snapshot_name}
TO 'repo_name'
[ON|EXCLUDE (
    'table_name' [partition (p1,...)]
)]
[properties (
    "content" = "metadata_only|all"
)]

RESTORE SNAPSHOT [db_name].{snapshot_name}
TO 'repo_name'
[EXCLUDE|ON (
    'table_name' [partition (p1,...)]
)]
[properties (
)]
```

Change-Id: I6ae7deb9fa4135294a6cfd3472c86e8ec9ce413a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-review Categorizes an issue or PR as actively needing an API review. approved Indicates a PR has been approved by one committer. area/backup Issues of PRS related to backup and restore kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backup and Restore support view and external table
2 participants