Final answer:
A Lambda function failure triggers retries and is handled depending on the event source, with mechanisms like a dead-letter queue and CloudWatch metrics in place to aid in diagnosing and resolving issues.
Step-by-step explanation:
When a Lambda function fails during the processing of an event, AWS Lambda can be configured to manage these errors in different ways depending on the event source. If the event source is a stream-based service like Amazon DynamoDB Streams or Kinesis, AWS Lambda will attempt to process the failing batch until the data expires.
For asynchronous invocation, failed events are retried twice before being sent to a dead-letter queue (DLQ) if it is configured. AWS Lambda also sends out a CloudWatch metric for the function's error count and can send an SNS notification about the failure.
To handle failures properly, you should have monitoring, logging, Dead Letter Queues, and retry mechanisms in place. Proper error handling ensures that your application is resilient and can handle unexpected failures gracefully.