Lesson 3 of 4 Monitoring and Troubleshooting Pipelines

Troubleshooting Glue, EMR and Redshift Workloads

This lesson explains where to look when a pipeline fails or slows down in each processing service, and a systematic approach that applies to all of them.

Learning outcomes

After completing this lesson, you will be able to:

  • Troubleshoot Glue jobs with logs, the Spark UI and observability metrics.
  • Find EMR logs and application histories.
  • Diagnose Redshift queries and loads with EXPLAIN and system tables.
  • Apply a systematic troubleshooting approach.

AWS Glue

Start with the job run error, then driver and executor logs in CloudWatch, the Spark UI and observability metrics.

ProblemFix
Out-of-memory errorsLarger or more workers; repartition
Data skewRepartitioning or salting
Many small filesgroupFiles or compaction
Data reprocessed or skippedCheck job bookmark settings
Cannot reach a databaseIAM role, KMS key policy, VPC subnet, a security group self-referencing rule, VPC endpoints
Troubleshooting

A failing Glue job

Exam skills 3.3.6 · 1.2.7

Find the fix for each Glue problem, choosing again until you find it.

Log in to try this activity Interactive activities are free with an account.

Amazon EMR

Amazon EMR clusters run many processes on many nodes, so troubleshooting starts with knowing where each kind of information is kept. Step, container and application logs are archived to Amazon S3, where they remain after the cluster is terminated, which matters for transient clusters that shut down when their work ends. The Spark History Server and the YARN ResourceManager user interface show the stages and tasks of each application, revealing slow stages, skewed tasks and memory errors.

Cluster-level events explain failures that are not caused by the code. Cluster events record Spot interruptions and node failures, which can kill running tasks, and managed scaling metrics explain why capacity rose or fell. A cluster that never reaches the running state often has a failed bootstrap action, a script that runs on each node at start-up, whose log in S3 shows the error.

Match the pairs

Troubleshooting EMR

Exam skills 3.3.6

Match each EMR problem with where to look.

Log in to try this activity Interactive activities are free with an account.

Amazon Redshift

Several tools assist in diagnosing problems with Redshift queries and loads. The following table describes what each tool reveals.

ToolShows
EXPLAINThe query plan; large broadcasts or redistributions stand out
SYS_QUERY_HISTORY, STL and SVL viewsRun times and steps
SYS_LOAD_ERROR_DETAIL / STL_LOAD_ERRORSWhy COPY failed: bad types, delimiters or dates
STV_LOCKSBlocking
WLM queue metricsWaiting queries
SVV_TABLE_INFOTable skew and unsorted data
Redshift AdvisorSuggested fixes
Match the pairs

Troubleshooting Redshift

Exam skills 3.3.4

Match each question with the Redshift tool that answers it.

Log in to try this activity Interactive activities are free with an account.

A general approach

Whatever the service, pipeline failures yield to a systematic approach rather than trial and error. The first step is to reproduce the problem with a small sample of the input, which makes each test run quick and isolates whether the cause lies in the data or in the code.

Next, recent changes to code, schemas or permissions are checked, because most failures in pipelines that used to work follow a change; AWS CloudTrail shows configuration and permission changes, and version control shows code changes. Comparing the failed run with recent successful runs, in input volumes, durations and logs, often points directly to the difference. Finally, once the problem is fixed, monitoring is added so that the next occurrence is detected sooner, ideally before consumers notice.

The following diagram shows the steps of the approach.

A systematic approach to pipeline failures. Reproduce the problem on a small sample, check recent changes to code, schemas and permissions, compare the failed run with recent successful runs, classify the cause as data, resource, network or permission, fix the cause and add monitoring so the next occurrence is caught sooner.
The same steps apply to Glue, EMR and Redshift.
Put in order

A troubleshooting approach

Exam skills 3.3.6

Put the steps of the general troubleshooting approach in order.

Log in to try this activity Interactive activities are free with an account.
Worked example

Three failures, three causes

Three pipeline failures each have a distinct cause. The following table identifies the likely cause of each symptom and the appropriate remedy.

SymptomLikely causeFix
Glue job fails with out-of-memory on one executorData skew or a very large fileRepartition, salt skewed keys, or use larger workers (G.2X)
Glue job cannot reach an RDS sourceConnection's subnet or security group, or no NAT or S3 endpointFix the Glue connection networking; self-referencing security group rule
EMR Spark job runs much longer than usualSpot task nodes reclaimed, or skewCheck the Spark UI stages; use instance fleets; fix skew
Redshift query slow after a large loadTable not vacuumed or analysed; stale statisticsRun (or let auto) VACUUM and ANALYZE
Redshift COPY failsFormat mismatch or permissionsQuery SYS_LOAD_ERROR_DETAIL; check the IAM role

The general approach is always the same: read the error or the slowest stage, identify whether it is a data, resource, network or permission problem, then fix the cause rather than adding capacity.

Check yourself

Where are the details of a failed Redshift COPY?

Show answer

In SYS_LOAD_ERROR_DETAIL or STL_LOAD_ERRORS.

Exam Tips

Remember for the exam

  • When COPY fails, check SYS_LOAD_ERROR_DETAIL or STL_LOAD_ERRORS.
  • When an EMR step fails, read the step logs in S3 and use the Spark History Server.
  • For Glue out-of-memory errors or skew, check observability metrics, use bigger workers and repartition.
  • When Glue cannot reach a database, check the security group's self-referencing rule, the subnets and the endpoints.
  • When Redshift slices are uneven, check skew in SVV_TABLE_INFO and change the distribution key.