[fix](multi-catalog) should load datasource before loading cluster (#10330)

A temp DataSourceMgr is created when catalog intializes, and will be
updated in the loadCluster process. However, the loadDatasource process
will create a new DataSourceMgr with no cluster updated, and write such
DatasourceMgr to image. Finally, when the doris starts to recover, no
cluster is available.
This commit is contained in:
Ashin Gau
2022-06-23 10:59:12 +08:00
committed by GitHub
parent 573ad57467
commit 815ea35578
2 changed files with 12 additions and 17 deletions

View File

@ -1878,15 +1878,13 @@ public class Catalog {
* Load datasource through file.
**/
public long loadDatasource(DataInputStream in, long checksum) throws IOException {
if (Config.enable_multi_catalog) {
DataSourceMgr mgr = DataSourceMgr.read(in);
// When enable the multi catalog in the first time, the mgr will be a null value.
// So ignore it to use default datasource manager.
if (mgr != null) {
this.dataSourceMgr = mgr;
}
LOG.info("finished replay datasource from image");
DataSourceMgr mgr = DataSourceMgr.read(in);
// When enable the multi catalog in the first time, the mgr will be a null value.
// So ignore it to use default datasource manager.
if (mgr != null) {
this.dataSourceMgr = mgr;
}
LOG.info("finished replay datasource from image");
return checksum;
}
@ -2159,10 +2157,7 @@ public class Catalog {
* Save datasource image.
*/
public long saveDatasource(CountingDataOutputStream out, long checksum) throws IOException {
// Do not write datasource image when enable multi catalog is false.
if (Config.enable_multi_catalog) {
Catalog.getCurrentCatalog().getDataSourceMgr().write(out);
}
Catalog.getCurrentCatalog().getDataSourceMgr().write(out);
return checksum;
}

View File

@ -34,11 +34,11 @@ public class PersistMetaModules {
// The write and read of meta modules should be in same order.
public static final List<MetaPersistMethod> MODULES_IN_ORDER;
public static final ImmutableList<String> MODULE_NAMES = ImmutableList.copyOf(
new String[] {"masterInfo", "frontends", "backends", "db", "loadJob", "alterJob", "recycleBin",
"globalVariable", "cluster", "broker", "resources", "exportJob", "syncJob", "backupHandler",
"paloAuth", "transactionState", "colocateTableIndex", "routineLoadJobs", "loadJobV2", "smallFiles",
"plugins", "deleteHandler", "sqlBlockRule", "policy", "datasource"});
public static final ImmutableList<String> MODULE_NAMES = ImmutableList.of(
"masterInfo", "frontends", "backends", "datasource", "db", "loadJob", "alterJob", "recycleBin",
"globalVariable", "cluster", "broker", "resources", "exportJob", "syncJob", "backupHandler",
"paloAuth", "transactionState", "colocateTableIndex", "routineLoadJobs", "loadJobV2", "smallFiles",
"plugins", "deleteHandler", "sqlBlockRule", "policy");
static {
MODULES_MAP = Maps.newHashMap();