in index.js [1289:1365]
function failBatch(loadState, config, thisBatchId, s3Info, manifestInfo) {
logger.info("Failing Batch " + thisBatchId + " due to " + JSON.stringify(loadState));
if (config.failedManifestKey && manifestInfo) {
// copy the manifest to the failed location
manifestInfo.failedManifestPrefix = manifestInfo.manifestPrefix.replace(manifestInfo.manifestKey + '/', config.failedManifestKey.S + '/');
manifestInfo.failedManifestPath = manifestInfo.manifestBucket + '/' + manifestInfo.failedManifestPrefix;
var copySpec = {
Bucket: manifestInfo.manifestBucket,
Key: manifestInfo.failedManifestPrefix,
CopySource: manifestInfo.manifestPath,
Metadata: {
'x-amz-meta-load-date': common.readableTime(common.now())
}
};
logger.debug("Moving manifest file to failure manifest prefix");
logger.debug(JSON.stringify(copySpec));
s3.copyObject(copySpec, function (err, data) {
if (err) {
logger.error(err);
closeBatch(err, config, thisBatchId, s3Info, manifestInfo);
} else {
logger.info('Created new Failed Manifest ' + manifestInfo.failedManifestPath);
// update the batch entry showing the failed
// manifest location
var manifestModification = {
Key: {
batchId: {
S: thisBatchId
},
s3Prefix: {
S: s3Info.prefix
}
},
TableName: batchTable,
AttributeUpdates: {
manifestFile: {
Action: 'PUT',
Value: {
S: manifestInfo.failedManifestPath
}
},
lastUpdate: {
Action: 'PUT',
Value: {
N: '' + common.now()
}
}
}
};
logger.debug("Marking new failure manifest location on Batch entry");
logger.debug(JSON.stringify(manifestModification));
common.retryableUpdate(dynamoDB, manifestModification, function (err, data) {
if (err) {
console.log(err);
// add this new error to the original failed load
// state
closeBatch(loadState + " " + err, config, thisBatchId, s3Info, manifestInfo);
} else {
// close the batch with the original
// calling error
closeBatch(loadState, config, thisBatchId, s3Info, manifestInfo);
}
});
}
});
} else {
logger.info('Not requesting copy of Manifest to Failed S3 Location');
closeBatch(loadState, config, thisBatchId, s3Info, manifestInfo);
}
};