Skip to content

Commit

Permalink
[improvement](meta) allow to ignore unknown image module (apache#25450)…
Browse files Browse the repository at this point in the history
… (apache#25968)

Add new FE config `ignore_unknown_metadata_module`. Default is false.
If set to true, when reading metadata image file, and there are unknown modules, these modules
will be ignored and skipped.
This is mainly used in downgrade operation, old version can be compatible with new version Image file.
  • Loading branch information
morningman committed Oct 30, 2023
1 parent b829874 commit 49d2688
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
14 changes: 14 additions & 0 deletions fe/fe-common/src/main/java/org/apache/doris/common/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -2161,4 +2161,18 @@ public class Config extends ConfigBase {
"min buckets of auto bucket"
})
public static int autobucket_min_buckets = 1;

@ConfField(description = {
"是否忽略 Image 文件中未知的模块。如果为 true,不在 PersistMetaModules.MODULE_NAMES 中的元数据模块将被忽略并跳过。"
+ "默认为 false,如果 Image 文件中包含未知的模块,Doris 将会抛出异常。"
+ "该参数主要用于降级操作中,老版本可以兼容新版本的 Image 文件。",
"Whether to ignore unknown modules in Image file. "
+ "If true, metadata modules not in PersistMetaModules.MODULE_NAMES "
+ "will be ignored and skipped. Default is false, if Image file contains unknown modules, "
+ "Doris will throw exception. "
+ "This parameter is mainly used in downgrade operation, "
+ "old version can be compatible with new version Image file."
})
public static boolean ignore_unknown_metadata_module = false;

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.doris.persist.meta;

import org.apache.doris.catalog.Env;
import org.apache.doris.common.Config;
import org.apache.doris.common.DdlException;

import com.google.common.base.Preconditions;
Expand Down Expand Up @@ -101,7 +102,7 @@ public static void read(File imageFile, Env env) throws IOException, DdlExceptio
}
// skip deprecated modules
if (PersistMetaModules.DEPRECATED_MODULE_NAMES.contains(metaIndex.name)) {
LOG.warn("meta modules {} is deprecated, ignore and skip it");
LOG.warn("meta modules {} is deprecated, ignore and skip it", metaIndex.name);
// If this is the last module, nothing need to do.
if (i < metaFooter.metaIndices.size() - 1) {
IOUtils.skipFully(dis, metaFooter.metaIndices.get(i + 1).offset - metaIndex.offset);
Expand All @@ -110,8 +111,17 @@ public static void read(File imageFile, Env env) throws IOException, DdlExceptio
}
MetaPersistMethod persistMethod = PersistMetaModules.MODULES_MAP.get(metaIndex.name);
if (persistMethod == null) {
throw new IOException("Unknown meta module: " + metaIndex.name + ". Known modules: "
+ PersistMetaModules.MODULE_NAMES);
if (Config.ignore_unknown_metadata_module) {
LOG.warn("meta modules {} is unknown, ignore and skip it", metaIndex.name);
// If this is the last module, nothing need to do.
if (i < metaFooter.metaIndices.size() - 1) {
IOUtils.skipFully(dis, metaFooter.metaIndices.get(i + 1).offset - metaIndex.offset);
}
continue;
} else {
throw new IOException("Unknown meta module: " + metaIndex.name + ". Known modules: "
+ PersistMetaModules.MODULE_NAMES);
}
}
checksum = (long) persistMethod.readMethod.invoke(env, dis, checksum);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class PersistMetaModules {

// Modules in this list is deprecated and will not be saved in meta file. (also should not be in MODULE_NAMES)
public static final ImmutableList<String> DEPRECATED_MODULE_NAMES = ImmutableList.of(
"loadJob", "cooldownJob");
"loadJob", "cooldownJob", "AnalysisMgrV2");

static {
MODULES_MAP = Maps.newHashMap();
Expand Down

0 comments on commit 49d2688

Please sign in to comment.