Skip to content

Commit

Permalink
[fix](fe) fix several blocking bugs (apache#37756)
Browse files Browse the repository at this point in the history
1. Redundant hashCode of FunctionCallExpr.java
This line is redundant, and will cause the amount of hashcode
calculation to grow exponentially.

2. A potential deadlock of external catalog
    The following case may causing this deadlock:
    - high frequency load.
    - querying external table join inner table on non-master FE. 
    - refresh external catalog frequently.

3. A workaround to avoid FE restart failure because db does not found
    introduced from apache#33610 and fixed in apache#36530.
    This PR is to make previous metadata restart successfully.
  • Loading branch information
morningman authored and wsjz committed Jul 15, 2024
1 parent 43bdb01 commit d0b1910
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2447,7 +2447,6 @@ public int hashCode() {
int result = super.hashCode();
result = 31 * result + Objects.hashCode(opcode);
result = 31 * result + Objects.hashCode(fnName);
result = 31 * result + Objects.hashCode(fnParams);
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,11 @@ public void replayInitCatalog(InitCatalogLog log) {
// Should not return null.
// Because replyInitCatalog can only be called when `use_meta_cache` is false.
// And if `use_meta_cache` is false, getDbForReplay() will not return null
if (!db.isPresent()) {
LOG.warn("met invalid db id {} in replayInitCatalog, catalog: {}, ignore it to skip bug.",
log.getRefreshDbIds().get(i), name);
continue;
}
Preconditions.checkNotNull(db.get());
tmpDbNameToId.put(db.get().getFullName(), db.get().getId());
tmpIdToDb.put(db.get().getId(), db.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,20 @@ public void forward(long catalogId, long dbId) throws Exception {
boolean isReturnToPool = false;
try {
TInitExternalCtlMetaResult result = client.initExternalCtlMeta(request);
Env.getCurrentEnv().getJournalObservable().waitOn(result.maxJournalId, waitTimeoutMs);
if (!result.getStatus().equalsIgnoreCase(STATUS_OK)) {
throw new UserException(result.getStatus());
} else {
// DO NOT wait on journal replayed, this may cause deadlock.
// 1. hold table read lock
// 2. wait on journal replayed
// 3. previous journal (eg, txn journal) replayed need to hold table write lock
// 4. deadlock
// But no waiting on journal replayed may cause some request on non-master FE failed for some time.
// There is no good solution for this.
// In feature version, this whole process is refactored, so we temporarily remove this waiting.
// Env.getCurrentEnv().getJournalObservable().waitOn(result.maxJournalId, timeoutMs);
isReturnToPool = true;
}
isReturnToPool = true;
} catch (Exception e) {
LOG.warn("Failed to finish forward init operation, please try again. ", e);
throw e;
Expand Down

0 comments on commit d0b1910

Please sign in to comment.