[fix](restore) Reset index id for MaterializedIndexMeta (#33831)
This commit is contained in:
@ -122,6 +122,10 @@ public class MaterializedIndexMeta implements Writable, GsonPostProcessable {
|
||||
return indexId;
|
||||
}
|
||||
|
||||
public void resetIndexIdForRestore(long id) {
|
||||
indexId = id;
|
||||
}
|
||||
|
||||
public KeysType getKeysType() {
|
||||
return keysType;
|
||||
}
|
||||
|
||||
@ -591,7 +591,9 @@ public class OlapTable extends Table implements MTMVRelatedTableIf {
|
||||
// base index
|
||||
baseIndexId = newIdxId;
|
||||
}
|
||||
indexIdToMeta.put(newIdxId, origIdxIdToMeta.get(entry.getKey()));
|
||||
MaterializedIndexMeta indexMeta = origIdxIdToMeta.get(entry.getKey());
|
||||
indexMeta.resetIndexIdForRestore(newIdxId);
|
||||
indexIdToMeta.put(newIdxId, indexMeta);
|
||||
indexNameToId.put(entry.getValue(), newIdxId);
|
||||
}
|
||||
|
||||
@ -1530,6 +1532,16 @@ public class OlapTable extends Table implements MTMVRelatedTableIf {
|
||||
this.indexNameToId.put(indexName, indexId);
|
||||
MaterializedIndexMeta indexMeta = MaterializedIndexMeta.read(in);
|
||||
indexIdToMeta.put(indexId, indexMeta);
|
||||
|
||||
// HACK: the index id in MaterializedIndexMeta is not equals to the index id
|
||||
// saved in OlapTable, because the table restore from snapshot is not reset
|
||||
// the MaterializedIndexMeta correctly.
|
||||
if (indexMeta.getIndexId() != indexId) {
|
||||
LOG.warn("HACK: the index id {} in materialized index meta of {} is not equals"
|
||||
+ " to the index saved in table {} ({}), reset it to {}",
|
||||
indexMeta.getIndexId(), indexName, name, id, indexId);
|
||||
indexMeta.resetIndexIdForRestore(indexId);
|
||||
}
|
||||
}
|
||||
|
||||
// partition and distribution info
|
||||
|
||||
Reference in New Issue
Block a user