[bug] Set timeout for entire conversion(wait results uploading); Remove result dir to reduce amount of data transferred in case of error

This commit is contained in:
Sergey Konovalov
2023-11-22 13:24:21 +03:00
parent 36d1c73590
commit 719fa59e98

View File

@ -40,6 +40,7 @@ var config = require('config');
var spawnAsync = require('@expo/spawn-async');
const bytes = require('bytes');
const lcid = require('lcid');
const ms = require('ms');
var commonDefines = require('./../../Common/sources/commondefines');
var storage = require('./../../Common/sources/storage-base');
@ -787,6 +788,10 @@ function* processUploadToStorageErrorFile(ctx, dataConvert, tempDirs, childRes,
let outputPath = path.join(tempDirs.temp, 'console.txt');
fs.writeFileSync(outputPath, output, {encoding: 'utf8'});
//remove result dir with temp dir inside(see m_sTempDir param) to reduce the amount of data transferred
//todo filter on upload
fs.rmSync(tempDirs.result, { recursive: true, force: true });
let format = path.extname(dataConvert.fileFrom).substring(1) || "unknown";
yield* processUploadToStorage(ctx, tempDirs.temp, format + '/' + dataConvert.key , false, tenErrorFiles);
@ -919,7 +924,7 @@ function* spawnProcess(ctx, builderParams, tempDirs, dataConvert, authorProps, g
}
let spawnAsyncPromise = spawnAsync(processPath, childArgs, spawnOptions);
childRes = spawnAsyncPromise.child;
let waitMS = task.getVisibilityTimeout() * 1000 - (new Date().getTime() - getTaskTime.getTime());
let waitMS = Math.max(0, task.getVisibilityTimeout() * 1000 - (new Date().getTime() - getTaskTime.getTime()));
timeoutId = setTimeout(function() {
isTimeout = true;
timeoutId = undefined;
@ -1099,7 +1104,8 @@ function ackTask(ctx, res, task, ack) {
});
}
function receiveTaskSetTimeout(ctx, task, ack, outParams) {
let delay = 1.1 * task.getVisibilityTimeout() * 1000;
//add DownloadTimeout to upload results
let delay = task.getVisibilityTimeout() * 1000 + ms(cfgDownloadTimeout.wholeCycle);
return setTimeout(function() {
return co(function*() {
outParams.isAck = true;