Skip to content

Commit

Permalink
[fix](restore) update is_being_synced properties (apache#40194)
Browse files Browse the repository at this point in the history
Some properties, like storage_policy, are not supported by the ccr
syncer. This PR maintains those properties for both local and remote
tables while restoring.
  • Loading branch information
w41ter authored Sep 5, 2024
1 parent 9faecb9 commit 1849425
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ private Status allTabletCommitted(boolean isReplay) {

// set all restored partition version and version hash
// set all tables' state to NORMAL
setTableStateToNormal(db, true, isReplay);
setTableStateToNormalAndUpdateProperties(db, true, isReplay);
for (long tblId : restoredVersionInfo.rowKeySet()) {
Table tbl = db.getTableNullable(tblId);
if (tbl == null) {
Expand Down Expand Up @@ -2055,7 +2055,7 @@ public void cancelInternal(boolean isReplay) {
Database db = env.getInternalCatalog().getDbNullable(dbId);
if (db != null) {
// rollback table's state to NORMAL
setTableStateToNormal(db, false, isReplay);
setTableStateToNormalAndUpdateProperties(db, false, isReplay);

// remove restored tbls
for (Table restoreTbl : restoredTbls) {
Expand Down Expand Up @@ -2135,7 +2135,7 @@ public void cancelInternal(boolean isReplay) {
LOG.info("finished to cancel restore job. is replay: {}. {}", isReplay, this);
}

private void setTableStateToNormal(Database db, boolean committed, boolean isReplay) {
private void setTableStateToNormalAndUpdateProperties(Database db, boolean committed, boolean isReplay) {
for (String tableName : jobInfo.backupOlapTableObjects.keySet()) {
Table tbl = db.getTableNullable(jobInfo.getAliasByOriginNameIfSet(tableName));
if (tbl == null) {
Expand Down Expand Up @@ -2178,6 +2178,9 @@ private void setTableStateToNormal(Database db, boolean committed, boolean isRep
DynamicPartitionScheduler.LAST_UPDATE_TIME, TimeUtils.getCurrentFormatTime());
}
}
if (committed && isBeingSynced) {
olapTbl.setBeingSyncedProperties();
}
} finally {
tbl.writeUnlock();
}
Expand Down
21 changes: 15 additions & 6 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -737,17 +737,26 @@ public void resetPropertiesForRestore(boolean reserveDynamicPartitionEnable, boo
tableProperty.resetPropertiesForRestore(reserveDynamicPartitionEnable, reserveReplica, replicaAlloc);
}
if (isBeingSynced) {
TableProperty tableProperty = getOrCreatTableProperty();
tableProperty.setIsBeingSynced();
tableProperty.removeInvalidProperties();
if (isAutoBucket()) {
markAutoBucket();
}
setBeingSyncedProperties();
}
// remove colocate property.
setColocateGroup(null);
}

/**
* Set the related properties when is_being_synced properties is true.
*
* Some properties, like storage_policy, colocate_with, are not supported by the ccr syncer.
*/
public void setBeingSyncedProperties() {
TableProperty tableProperty = getOrCreatTableProperty();
tableProperty.setIsBeingSynced();
tableProperty.removeInvalidProperties();
if (isAutoBucket()) {
markAutoBucket();
}
}

public void resetVersionForRestore() {
for (Partition partition : idToPartition.values()) {
partition.setNextVersion(partition.getVisibleVersion() + 1);
Expand Down

0 comments on commit 1849425

Please sign in to comment.