修复--将已经正常完成的任务错误识别为死任务,并重新执行的问题 #328
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
由于任务从“等待执行队列”向“执行中队列”切换时,任务的gmt_created时间是任务被放入“等待执行队列”的时间,如果任务在等待执行队列滞留时间超过30秒,那么被切换到“执行中队列”的这些任务,都会被jobtracker认为疑似死任务(在执行中队列的任务从gmt_created算起,超过30秒被认为疑似死任务),这时jobtracker会向tasktracker请求这些疑似死任务在tasktracker中的状态,如果恰好这时有的任务已经执行完成,tasktracker就会返回这个任务的isRunning为0,jobtracker就会将这个任务识别为死任务,进行修复重新执行。但实际上这个任务是已经执行完成的,造成任务重复执行的问题。
修改的思路是,在com.github.ltsopensource.jobtracker.sender.JobSender进行任务切换时(从“等待执行队列”向“执行中队列”切换),更新gmt_modified为当前时间,在MysqlExecutingJobQueue.getDeadJobs方法中,判断gmt_modified(将gmt_created改为gmt_modified)的时间晚于deadline,实现疑似死任务的准确判断。