Restart Rule Example

The following example describes a rule that is evaluated when queries are restarted because of an error.

Restart and Try to Expand Resources

The flex profile has a predefined rule, flex_expandResourcesErrorHandler, which attempts to increase the resources available to a query that errors out with one of several specified error codes. The attempt to expand resources happens when the query restarts and only applies to the flex profile.

The rule is defined as follows:
log.info(w + ' is restarting for error ' + w.errorCode);
if (String(w.errorCode).match(/53200|KE002|YB004|KE032|KE029|YB006|EEOOM/)) {

  // See if we can't expand resources; if we can, lets try the query with more resources.
  if (!wlm.assignMaximumResources(w)) {
     w.errorRecoverable = false;
     log.info(w + ' cannot expand resources; marked as not recoverable');
  } else {
     log.info(w + ' expanded resources for restart (memory ' + w.requestedMemoryMB + ', spill ' + w.requestedSpillMB + ')');
  }
}

The wlm.assignMaximumResources(w) property returns true if expanded resources (memory and spill space) are available from the flex pool. Additional resources may or may not be available, depending on concurrent query activity in that pool. This rule also logs appropriate INFO messages, either marking the query as not recoverable or listing the resources available on restart.

See also Recoverable Error Codes.