Skip to content

Commit

Permalink
[enhancement](delete) Using insert timeout session var to control del…
Browse files Browse the repository at this point in the history
…ete job timeout (apache#41063)
  • Loading branch information
TangSiyang2001 committed Sep 29, 2024
1 parent 34429bf commit abe4bcf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
14 changes: 11 additions & 3 deletions fe/fe-core/src/main/java/org/apache/doris/load/DeleteJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ public enum DeleteState {

private MarkedCountDownLatch<Long, Long> countDownLatch;

private long timeoutS = 300L;

public DeleteJob(long id, long transactionId, String label,
Map<Long, Short> partitionReplicaNum, DeleteInfo deleteInfo) {
this.id = id;
Expand Down Expand Up @@ -250,14 +252,16 @@ public Collection<TabletDeleteInfo> getTabletDeleteInfo() {
return tabletDeleteInfoMap.values();
}

public void setTimeoutS(long timeoutS) {
this.timeoutS = timeoutS;
}

public long getTimeoutMs() {
if (FeConstants.runningUnitTest) {
// for making unit test run fast
return 1000;
}
// timeout is between 30 seconds to 5 min
long timeout = Math.max(totalTablets.size() * Config.tablet_delete_timeout_second * 1000L, 30000L);
return Math.min(timeout, Config.delete_job_max_timeout_second * 1000L);
return timeoutS * 1000L;
}

public void setTargetDb(Database targetDb) {
Expand Down Expand Up @@ -550,6 +554,10 @@ public DeleteJob buildWith(BuildParams params) throws Exception {
deleteJob.setTargetDb(params.getDb());
deleteJob.setTargetTbl(params.getTable());
deleteJob.setCountDownLatch(new MarkedCountDownLatch<>((int) replicaNum));
ConnectContext connectContext = ConnectContext.get();
if (connectContext != null) {
deleteJob.setTimeoutS(connectContext.getExecTimeout());
}
return deleteJob;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,11 @@ public boolean isSyncLoadKindStmt() {
return logicalPlan instanceof InsertIntoTableCommand
|| logicalPlan instanceof InsertOverwriteTableCommand
|| (logicalPlan instanceof CreateTableCommand
&& ((CreateTableCommand) logicalPlan).isCtasCommand());
&& ((CreateTableCommand) logicalPlan).isCtasCommand())
|| logicalPlan instanceof DeleteFromCommand;
}
return parsedStmt instanceof InsertStmt || parsedStmt instanceof InsertOverwriteTableStmt
|| parsedStmt instanceof CreateTableAsSelectStmt;
|| parsedStmt instanceof CreateTableAsSelectStmt || parsedStmt instanceof DeleteStmt;
}

public boolean isAnalyzeStmt() {
Expand Down

0 comments on commit abe4bcf

Please sign in to comment.