Fix NPE in postCleanupStage if stage doesn't exist (#13742)

With fault tolerance enabled in MSQ, not all the work orders might be populated if the worker is restarted. In case it gets the request for cleaning up the stage which is not present in the worker's map, it can throw an NPE. Added a check to ensure that the stage is present in the map before cleaning it up, or else logging it as a warning.
This commit is contained in:
Laksh Singla 2023-02-06 19:13:39 +05:30 committed by GitHub
parent c5835c29a1
commit 9100a61bf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -574,7 +574,12 @@ public class WorkerImpl implements Worker
holder -> {
cleanStageOutput(stageId, true);
// Mark the stage as FINISHED
holder.getStageKernelMap().get(stageId).setStageFinished();
WorkerStageKernel stageKernel = holder.getStageKernelMap().get(stageId);
if (stageKernel == null) {
log.warn("Stage id [%s] non existent. Unable to mark the stage kernel for it as FINISHED", stageId);
} else {
stageKernel.setStageFinished();
}
}
);
}