[enhancement](delete) Using insert timeout session var to control delete job timeout (#41063) (#41475)

## Proposed changes

pick: #41063
This commit is contained in:
Siyang Tang
2024-10-08 12:03:30 +08:00
committed by GitHub
parent cb24ccc112
commit 3355ebe5e7
2 changed files with 15 additions and 5 deletions

View File

@ -120,6 +120,8 @@ public class DeleteJob extends AbstractTxnStateChangeCallback implements DeleteJ
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;
@ -250,14 +252,16 @@ public class DeleteJob extends AbstractTxnStateChangeCallback implements DeleteJ
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) {
@ -550,6 +554,10 @@ public class DeleteJob extends AbstractTxnStateChangeCallback implements DeleteJ
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;
}

View File

@ -145,6 +145,7 @@ import org.apache.doris.nereids.parser.NereidsParser;
import org.apache.doris.nereids.rules.exploration.mv.InitMaterializationContextHook;
import org.apache.doris.nereids.trees.plans.commands.Command;
import org.apache.doris.nereids.trees.plans.commands.CreateTableCommand;
import org.apache.doris.nereids.trees.plans.commands.DeleteFromCommand;
import org.apache.doris.nereids.trees.plans.commands.Forward;
import org.apache.doris.nereids.trees.plans.commands.NotAllowFallback;
import org.apache.doris.nereids.trees.plans.commands.PrepareCommand;
@ -479,10 +480,11 @@ public class StmtExecutor {
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() {