Skip to content

Commit

Permalink
[Fix](multi-catalog) Fix NPE when refreshing catalog on Slave FE. (#3…
Browse files Browse the repository at this point in the history
…1335)


---------

Co-authored-by: wangxiangyu <[email protected]>
  • Loading branch information
2 people authored and Doris-Extras committed Feb 23, 2024
1 parent b6ca76e commit 49842ee
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.doris.datasource.hive.event;

import org.apache.doris.analysis.RedirectStatus;
import org.apache.doris.analysis.UserIdentity;
import org.apache.doris.catalog.Env;
import org.apache.doris.common.Config;
import org.apache.doris.common.util.MasterDaemon;
Expand All @@ -29,6 +30,7 @@
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.MasterOpExecutor;
import org.apache.doris.qe.OriginStatement;
import org.apache.doris.system.SystemInfoService;

import com.google.common.collect.Maps;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -264,7 +266,7 @@ private NotificationEventResponse getNextEventResponseForSlave(HMSExternalCatalo
// Need a fallback to handle this because this error state can not be recovered until restarting FE
if (StringUtils.isNotEmpty(e.getMessage())
&& e.getMessage().contains(HiveMetaStoreClient.REPL_EVENTS_MISSING_IN_METASTORE)) {
refreshCatalogForMaster(hmsExternalCatalog);
refreshCatalogForSlave(hmsExternalCatalog);
// set masterLastSyncedEventId to lastSyncedEventId after refresh catalog successfully
updateLastSyncedEventId(hmsExternalCatalog, masterLastSyncedEventId);
LOG.warn("Notification events are missing, maybe an event can not be handled "
Expand Down Expand Up @@ -314,8 +316,13 @@ private void refreshCatalogForSlave(HMSExternalCatalog hmsExternalCatalog) throw
// Transfer to master to refresh catalog
String sql = "REFRESH CATALOG " + hmsExternalCatalog.getName();
OriginStatement originStmt = new OriginStatement(sql, 0);
MasterOpExecutor masterOpExecutor = new MasterOpExecutor(originStmt, new ConnectContext(),
RedirectStatus.FORWARD_WITH_SYNC, false);
ConnectContext ctx = new ConnectContext();
ctx.setQualifiedUser(UserIdentity.ROOT.getQualifiedUser());
ctx.setCurrentUserIdentity(UserIdentity.ROOT);
ctx.setEnv(Env.getCurrentEnv());
ctx.setCluster(SystemInfoService.DEFAULT_CLUSTER);
MasterOpExecutor masterOpExecutor = new MasterOpExecutor(originStmt, ctx,
RedirectStatus.FORWARD_WITH_SYNC, false);
if (LOG.isDebugEnabled()) {
LOG.debug("Transfer to master to refresh catalog, stmt: {}", sql);
}
Expand Down

0 comments on commit 49842ee

Please sign in to comment.