Skip to content

Commit 3ed9ed7

Browse files
TangSiyang2001dataroaring
authored andcommitted
[enhancement](delete) Using insert timeout session var to control delete job timeout (#41063)
1 parent a91f8b1 commit 3ed9ed7

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

fe/fe-core/src/main/java/org/apache/doris/load/DeleteJob.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ public enum DeleteState {
121121

122122
private MarkedCountDownLatch<Long, Long> countDownLatch;
123123

124+
private long timeoutS = 300L;
125+
124126
public DeleteJob(long id, long transactionId, String label,
125127
Map<Long, Short> partitionReplicaNum, DeleteInfo deleteInfo) {
126128
this.id = id;
@@ -251,14 +253,16 @@ public Collection<TabletDeleteInfo> getTabletDeleteInfo() {
251253
return tabletDeleteInfoMap.values();
252254
}
253255

256+
public void setTimeoutS(long timeoutS) {
257+
this.timeoutS = timeoutS;
258+
}
259+
254260
public long getTimeoutMs() {
255261
if (FeConstants.runningUnitTest) {
256262
// for making unit test run fast
257263
return 1000;
258264
}
259-
// timeout is between 30 seconds to 5 min
260-
long timeout = Math.max(totalTablets.size() * Config.tablet_delete_timeout_second * 1000L, 30000L);
261-
return Math.min(timeout, Config.delete_job_max_timeout_second * 1000L);
265+
return timeoutS * 1000L;
262266
}
263267

264268
public void setTargetDb(Database targetDb) {
@@ -563,6 +567,10 @@ public DeleteJob buildWith(BuildParams params) throws Exception {
563567
deleteJob.setTargetDb(params.getDb());
564568
deleteJob.setTargetTbl(params.getTable());
565569
deleteJob.setCountDownLatch(new MarkedCountDownLatch<>((int) replicaNum));
570+
ConnectContext connectContext = ConnectContext.get();
571+
if (connectContext != null) {
572+
deleteJob.setTimeoutS(connectContext.getExecTimeout());
573+
}
566574
return deleteJob;
567575
}
568576

fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,10 +499,11 @@ public boolean isSyncLoadKindStmt() {
499499
return logicalPlan instanceof InsertIntoTableCommand
500500
|| logicalPlan instanceof InsertOverwriteTableCommand
501501
|| (logicalPlan instanceof CreateTableCommand
502-
&& ((CreateTableCommand) logicalPlan).isCtasCommand());
502+
&& ((CreateTableCommand) logicalPlan).isCtasCommand())
503+
|| logicalPlan instanceof DeleteFromCommand;
503504
}
504505
return parsedStmt instanceof InsertStmt || parsedStmt instanceof InsertOverwriteTableStmt
505-
|| parsedStmt instanceof CreateTableAsSelectStmt;
506+
|| parsedStmt instanceof CreateTableAsSelectStmt || parsedStmt instanceof DeleteStmt;
506507
}
507508

508509
public boolean isAnalyzeStmt() {

0 commit comments

Comments
 (0)