Skip to content

Commit

Permalink
[fix](Export) fix dead lock of parallel Exporting (apache#43083)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?
Problem Summary:
There are 2 locks, lock of ExportMgr and lock of ExportJob(synchronized
lock).
Previously, the lock order is wrong:
1. When cancelling job, it will first get job lock, then getting mgr
lock.
2. When removing old job, it will first get mgr lock, then getting job
lock.

This PR fix it by always getting job lock after mgr lock, to avoid dead lock.
  • Loading branch information
BePPPower authored Nov 2, 2024
1 parent 9b6bee5 commit 399b437
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions fe/fe-core/src/main/java/org/apache/doris/load/ExportJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ private void cancelExportJobUnprotected(ExportFailMsg.CancelType type, String ms
if (FeConstants.runningUnitTest) {
return;
}
Env.getCurrentEnv().getEditLog().logExportUpdateState(id, ExportJobState.CANCELLED);
Env.getCurrentEnv().getEditLog().logExportUpdateState(this, ExportJobState.CANCELLED);
}

private void exportExportJob() {
Expand Down Expand Up @@ -749,7 +749,7 @@ private void finishExportJobUnprotected() {
outfileInfo = GsonUtils.GSON.toJson(allOutfileInfo);
// Clear the jobExecutorList to release memory.
jobExecutorList.clear();
Env.getCurrentEnv().getEditLog().logExportUpdateState(id, ExportJobState.FINISHED);
Env.getCurrentEnv().getEditLog().logExportUpdateState(this, ExportJobState.FINISHED);
}

public void replayExportJobState(ExportJobState newState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ public ExportJobStateTransfer() {
}

// used for persisting one log
public ExportJobStateTransfer(long jobId, ExportJobState state) {
this.jobId = jobId;
public ExportJobStateTransfer(ExportJob job, ExportJobState state) {
this.jobId = job.getId();
this.state = state;
ExportJob job = Env.getCurrentEnv().getExportMgr().getJob(jobId);
this.startTimeMs = job.getStartTimeMs();
this.finishTimeMs = job.getFinishTimeMs();
this.failMsg = job.getFailMsg();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1621,8 +1621,8 @@ public void logUpdateCloudReplicas(List<UpdateCloudReplicaInfo> infos) throws IO
}
}

public void logExportUpdateState(long jobId, ExportJobState newState) {
ExportJobStateTransfer transfer = new ExportJobStateTransfer(jobId, newState);
public void logExportUpdateState(ExportJob job, ExportJobState newState) {
ExportJobStateTransfer transfer = new ExportJobStateTransfer(job, newState);
logEdit(OperationType.OP_EXPORT_UPDATE_STATE, transfer);
}

Expand Down

0 comments on commit 399b437

Please sign in to comment.