diff --git a/fe/fe-core/src/main/java/com/starrocks/alter/AlterJobV2.java b/fe/fe-core/src/main/java/com/starrocks/alter/AlterJobV2.java index 834e5f0890c6d..1b238e9c2202a 100644 --- a/fe/fe-core/src/main/java/com/starrocks/alter/AlterJobV2.java +++ b/fe/fe-core/src/main/java/com/starrocks/alter/AlterJobV2.java @@ -223,9 +223,7 @@ public long getWarehouseId() { */ public synchronized void run() { if (isTimeout()) { - boolean cancelled = cancelImpl("Timeout"); - cancelHook(cancelled); - if (cancelled) { + if (cancelInternal("Timeout")) { // If this job can't be cancelled, we should execute it. return; } @@ -259,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); } } diff --git a/fe/fe-core/src/main/java/com/starrocks/alter/LakeTableSchemaChangeJob.java b/fe/fe-core/src/main/java/com/starrocks/alter/LakeTableSchemaChangeJob.java index 21a6e5e9c0afc..0cef06b5d7b61 100644 --- a/fe/fe-core/src/main/java/com/starrocks/alter/LakeTableSchemaChangeJob.java +++ b/fe/fe-core/src/main/java/com/starrocks/alter/LakeTableSchemaChangeJob.java @@ -1080,9 +1080,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); diff --git a/fe/fe-core/src/main/java/com/starrocks/alter/RollupJobV2.java b/fe/fe-core/src/main/java/com/starrocks/alter/RollupJobV2.java index d9538eb4fe84b..54939589534e0 100644 --- a/fe/fe-core/src/main/java/com/starrocks/alter/RollupJobV2.java +++ b/fe/fe-core/src/main/java/com/starrocks/alter/RollupJobV2.java @@ -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); diff --git a/fe/fe-core/src/main/java/com/starrocks/alter/SchemaChangeJobV2.java b/fe/fe-core/src/main/java/com/starrocks/alter/SchemaChangeJobV2.java index 19c32b871839e..5545a0ef9ed5a 100644 --- a/fe/fe-core/src/main/java/com/starrocks/alter/SchemaChangeJobV2.java +++ b/fe/fe-core/src/main/java/com/starrocks/alter/SchemaChangeJobV2.java @@ -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);