Skip to content

Commit

Permalink
[BugFix] fix ingestion hang because of alter job timeout (#55207)
Browse files Browse the repository at this point in the history
(cherry picked from commit 834532c)
  • Loading branch information
luohaha authored and mergify[bot] committed Jan 20, 2025
1 parent b81bf9b commit cf2241b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
18 changes: 12 additions & 6 deletions fe/fe-core/src/main/java/com/starrocks/alter/AlterJobV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,10 @@ public long getWarehouseId() {
*/
public synchronized void run() {
if (isTimeout()) {
cancelHook(cancelImpl("Timeout"));
return;
if (cancelInternal("Timeout")) {
// If this job can't be cancelled, we should execute it.
return;
}
}

// create connectcontext
Expand Down Expand Up @@ -255,15 +257,19 @@ public synchronized void run() {
} // else: handle the new state
}
} catch (AlterCancelException e) {
cancelHook(cancelImpl(e.getMessage()));
cancelInternal(e.getMessage());
}
}

protected boolean cancelInternal(String errMsg) {
boolean cancelled = cancelImpl(errMsg);
cancelHook(cancelled);
return cancelled;
}

public boolean cancel(String errMsg) {
synchronized (this) {
boolean cancelled = cancelImpl(errMsg);
cancelHook(cancelled);
return cancelled;
return cancelInternal(errMsg);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -938,9 +938,7 @@ public final boolean cancel(String errMsg) {
createReplicaLatch.countDownToZero(new Status(TStatusCode.OK, ""));
}
synchronized (this) {
boolean cancelled = cancelImpl(errMsg);
cancelHook(cancelled);
return cancelled;
return cancelInternal(errMsg);
}
} finally {
isCancelling.set(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -770,9 +770,7 @@ public final boolean cancel(String errMsg) {
createReplicaLatch.countDownToZero(new Status(TStatusCode.OK, ""));
}
synchronized (this) {
boolean cancelled = cancelImpl(errMsg);
cancelHook(cancelled);
return cancelled;
return cancelInternal(errMsg);
}
} finally {
isCancelling.set(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2103,7 +2103,7 @@ public AlterJobV2 createAlterMetaJob(AlterClause alterClause, Database db, OlapT
long timeoutSecond = PropertyAnalyzer.analyzeTimeout(properties, Config.alter_table_timeout_second);
alterMetaJob = new LakeTableAlterMetaJob(GlobalStateMgr.getCurrentState().getNextId(),
db.getId(),
olapTable.getId(), olapTable.getName(), timeoutSecond,
olapTable.getId(), olapTable.getName(), timeoutSecond * 1000 /* should be ms*/,
TTabletMetaType.ENABLE_PERSISTENT_INDEX, enablePersistentIndex, persistentIndexType);
} else {
// shouldn't happen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -946,9 +946,7 @@ public final boolean cancel(String errMsg) {
createReplicaLatch.countDownToZero(new Status(TStatusCode.OK, ""));
}
synchronized (this) {
boolean cancelled = cancelImpl(errMsg);
cancelHook(cancelled);
return cancelled;
return cancelInternal(errMsg);
}
} finally {
isCancelling.set(false);
Expand Down

0 comments on commit cf2241b

Please sign in to comment.