This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new b9be1b7c892 [fix](restore) Reset index id for MaterializedIndexMeta
(#33835)
b9be1b7c892 is described below
commit b9be1b7c8923a51c5417719b90e5e252d1707904
Author: walter <[email protected]>
AuthorDate: Thu Apr 18 17:04:14 2024 +0800
[fix](restore) Reset index id for MaterializedIndexMeta (#33835)
Cherry-pick #33831
---
.../org/apache/doris/catalog/MaterializedIndexMeta.java | 4 ++++
.../src/main/java/org/apache/doris/catalog/OlapTable.java | 14 +++++++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/catalog/MaterializedIndexMeta.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/MaterializedIndexMeta.java
index 415d34accdc..b9d4de727cd 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/catalog/MaterializedIndexMeta.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/catalog/MaterializedIndexMeta.java
@@ -122,6 +122,10 @@ public class MaterializedIndexMeta implements Writable,
GsonPostProcessable {
return indexId;
}
+ public void resetIndexIdForRestore(long id) {
+ indexId = id;
+ }
+
public KeysType getKeysType() {
return keysType;
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
index 8dc5193180c..d5ecc01febb 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
@@ -567,7 +567,9 @@ public class OlapTable extends Table {
// 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);
}
@@ -1462,6 +1464,16 @@ public class OlapTable extends Table {
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
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]