Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 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 @@ -669,17 +669,27 @@ public Status resetIdsForRestore(Env env, Database db, ReplicaAllocation restore
// entry.getKey() is the new partition id, use it to get the restore specified
// replica allocation
ReplicaAllocation replicaAlloc = partitionInfo.getReplicaAllocation(entry.getKey());
// save the materialized indexes before create new index, to avoid ids confliction
// between two cluster.
Map<Long, MaterializedIndex> idToIndex = Maps.newHashMap();
for (Map.Entry<Long, String> entry2 : origIdxIdToName.entrySet()) {
MaterializedIndex idx = partition.getIndex(entry2.getKey());
long newIdxId = indexNameToId.get(entry2.getValue());
int schemaHash = indexIdToMeta.get(newIdxId).getSchemaHash();
idx.setIdForRestore(newIdxId);
idToIndex.put(newIdxId, idx);
if (newIdxId != baseIndexId) {
// not base table, reset
// not base table, delete it.
partition.deleteRollupIndex(entry2.getKey());
}
}
for (Map.Entry<Long, MaterializedIndex> entry2 : idToIndex.entrySet()) {
Long idxId = entry2.getKey();
MaterializedIndex idx = entry2.getValue();
if (idxId != baseIndexId) {
// not base table, add it.
partition.createRollupIndex(idx);
}

int schemaHash = indexIdToMeta.get(idxId).getSchemaHash();
// generate new tablets in origin tablet order
int tabletNum = idx.getTablets().size();
idx.clearTabletsForRestore();
Expand Down Expand Up @@ -712,6 +722,15 @@ public Status resetIdsForRestore(Env env, Database db, ReplicaAllocation restore
partition.setIdForRestore(entry.getKey());
}

// reset the indexes and update the indexes in materialized index meta too.
List<Index> indexes = this.indexes.getIndexes();
for (Index idx : indexes) {
idx.setIndexId(env.getNextId());
}
for (Map.Entry<Long, MaterializedIndexMeta> entry : indexIdToMeta.entrySet()) {
entry.getValue().setIndexes(indexes);
}

return Status.OK;
}

Expand Down