Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

change SIGKILL to SIGTERM in local mode cancel trial job #3173

Merged
merged 7 commits into from
Dec 15, 2020
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion ts/nni_manager/training_service/local/localTrainingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,16 @@ class LocalTrainingService implements TrainingService {

return Promise.resolve();
}
tkill(trialJob.pid, 'SIGKILL');
tkill(trialJob.pid, 'SIGTERM');
const pid = trialJob.pid;
setTimeout(((pid: number): void => {
tkill(pid, 'SIGKILL', (err) => {
if (err){
this.log.warning(`cancel trial job {pid: ${pid}} failed: ${err.message}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suddenly thought of a problem.
If the pid get reused between SIGTERM and SIGKILL, this will kill a random process.
If you don't want to elegantly solve the problem in this release, I suggest to reduce the delay to minimize risk.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and other place use kill pid also has this risk, maybe elegant way is let them kill themselves, need discuss. This release reduce the delay to 1 second.

}
});
}).bind(this), 1000, pid);

this.setTrialJobStatus(trialJob, getJobCancelStatus(isEarlyStopped));

return Promise.resolve();
Expand Down