0

Below if my code of orchestrator, I am using combination of chaining and fanin/fanout

    const df = require("durable-functions");
const geocodeActivity = "getActualData";
const getDataActivity = "getDataFromDB";
const ld = require('lodash')

module.exports = df.orchestrator(function* (context) {
const outputs = [];
const parallelTasks = [];
try {
let payload = context.bindingData.input;
payload.dataType = "truth";
let truthData = yield context.df.callActivity(getDataActivity, payload);

    for (const data of truthData) {
        const truthDataObj = payload;
        truthDataObj.data = data;
        //console.log("ORCHESTRATOR: " + JSON.stringify(truthDataObj));
        parallelTasks.push(context.df.callActivity(geocodeActivity, ld.cloneDeep(truthDataObj)));
    }
    let actualData = yield context.df.Task.all(parallelTasks);
    let uploadDataInfo = payload;
    uploadDataInfo['actual_data'] = actualData;
    let uploadedCsv = yield context.df.callActivity("uploadActualData", uploadDataInfo);
    if (uploadedCsv == false || uploadedCsv == null || uploadedCsv === undefined) {
        outputs.push("failed");
    } else {
        outputs.push(uploadedCsv);
    }

} catch (err) {
    context.log(JSON.stringify(err));
    outputs.push('-1');
}
return outputs;

I am having below observations

Many times the orchestrators keeps stuck in running

The 1st Activity that is called for getDataActivity, returns record from DB, that can go upto million in rows and each row containing atleats 20 columns

Then I am looping through each record and performing some actions

But I have observed many times that it gets stuck in running or sometimes the server on which orchestrator is running gets restarted

Is it something to do with the huge amount of data that is getting returned from "GetDataActivity"? If yes what are your advise here, how can I try to solve this

Tarun
  • 517
  • 4
  • 9
  • 24
  • Additionally, I was able to see following error as well - I finally was able to see below error FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory How can i fix this? – Tarun Oct 22 '19 at 22:46
  • Which technology stack do you use? What is your JavaScript version? – Cindy Pau Oct 23 '19 at 02:56
  • Please show more details about your problem. That will be helpful to solve this problem. – Cindy Pau Oct 23 '19 at 02:57

1 Answers1

0

This error comes from run out of memory. Heap memory consumption exceeds the limit and JavaScript crash your process. To set it higher, you can use --max-old-space-size. But don't set too high because it will cause your system run out of memory.

usage of --max-old-space-size:

node --max-old-space-size=4096 index.js
Cindy Pau
  • 13,085
  • 1
  • 15
  • 27