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

Commit

Permalink
remove task histories with unreasonable task attempt index
Browse files Browse the repository at this point in the history
  • Loading branch information
suiguoxin committed Oct 21, 2020
1 parent 22647c1 commit aa3e071
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/rest-server/src/models/v2/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

// module dependencies
const logger = require('@pai/config/logger');
const { Op } = require('sequelize');
const databaseModel = require('@pai/utils/dbUtils');
const { encodeName } = require('@pai/models/v2/utils/name');
const createError = require('@pai/utils/error');
Expand Down Expand Up @@ -95,7 +96,16 @@ const get = async (frameworkName, jobAttemptIndex, taskRoleName, taskIndex) => {
try {
taskHistories = await databaseModel.TaskHistory.findAll({
attributes: ['snapshot'],
where: { taskUid: taskUid },
where: {
[Op.and]: [
{ taskUid: taskUid },
{
taskAttemptIndex: {
[Op.lt]: taskStatus.attemptStatus.id,
},
},
],
},
order: [['taskAttemptIndex', 'DESC']],
});
} catch (error) {
Expand Down

0 comments on commit aa3e071

Please sign in to comment.