System Response After a Map/Reduce Interruption

A map/reduce script can be interrupted at any time. For example, an application server disruption immediately stops the script. An uncaught error also stops the current function invocation, even if it's incomplete.

For more details, review the following sections:

Important:

Regardless of the script configuration, include logic to check for restarts. If the script has been restarted, prevent duplicate processing. For details, see Adding Logic to Handle Map/Reduce Restarts.

System Response After an Application-Server Disruption

An application disruption can happen due to a NetSuite update, maintenance, or execution environment failure. After the application server restarts, the script restarts, resuming the same stage it was in when interrupted.

When an application server restart interrupts the map or reduce stage, the system writes the SSS_APP_SERVER_RESTART error code to the relevant iterators. This error code is displayed with any uncaught error codes that were thrown.

For more details, see the following table.

Stage where interruption occurred

Script behavior

SSS_APP_SERVER_RESTART error code written to

getInputData

The script stops executing when disrupted.

The system restarts the function after the application server restarts.

map

The script stops executing when disrupted.

Any data that was saved during the previous invocation by using the context.write() method is discarded. Afterward, the response is as follows:

  1. The system evaluates the retryCount config setting. If retryCount is set to a value greater than 0 or if the retryCount setting isn't used, the script tries to process the same set of key-value pairs it was processing when the application server became unavailable. This data includes all pairs that were flagged for processing but not marked complete. However, if retryCount is set to 0, the script moves on to Step 2 without attempting further processing for these key-value pairs.

  2. The job moves on to other key-value pairs that require processing and were not previously flagged as in progress.

  • mapContext.errors — Contains the error codes recorded during previous attempts to process the current key-value pair.

  • mapSummary.errors — Contains all error codes recorded during the map stage.

reduce

  • reduceContext.errors — Contains the error codes recorded during previous attempts to process the current key-value pair.

  • reduceSummary.errors — Contains all error codes recorded during the reduce stage.

summarize

When the disruption occurs, the entire script stops executing.

After the application server restarts, the system restarts the function.

System Response After an Uncaught Error

An uncaught error doesn't necessarily stop the script, but it can disrupt its work. Some of this behavior can be configured. For details, see the following table.

Stage where error occurred

Script behavior

Errors written to

getInputData

The script ends the function invocation and exits the stage. It goes directly to the summarize stage. This behavior cannot be configured.

inputSummary.error

map

The function invocation ends when an error occurs, even if incomplete. Any data that was saved during the invocation by using the context.write() method is discarded. Afterward, the system responds as follows:

  1. The system evaluates the retryCount setting. If retryCount is set to a value greater than 0, and the maximum number of retries has not yet been used, the script tries to process the same key-value pair again. The rest of the steps in this process are not used.

  2. The system evaluates the exitOnError setting. If exitOnError is true, the script exits the stage and goes to summarize. The rest of the steps in this process are not used.

  3. The job continues with other key-value pairs that need processing. It does not do any further work on the pair it was processing when the error occurred.

  • mapContext.errors — Contains the error codes recorded during previous attempts to process the current key-value pair.

  • mapSummary.errors — Contains all error codes recorded during the map stage.

reduce

  • reduceContext.errors — Contains the error codes recorded during previous attempts to process the current key-value pair.

  • reduceSummary.errors — Contains all error codes recorded during the reduce stage.

summarize

The script stops executing. This behavior cannot be configured.

Note:

This table describes the behavior for the majority of errors, but a few errors result in different behavior. For example, if one of the jobs being processed in the map or reduce stage fails on SSS_USAGE_LIMIT_EXCEEDED, other jobs in Processing status are normally finished and their executions are not interrupted, but jobs in Pending status are canceled immediately. For details, see Hard Limits on Total Persisted Data.

Related Topics

General Notices