Skip to content

s3: autoDeleteObjects lambda chokes/hangs on large buckets #30573

@isker

Description

@isker

Describe the bug

I recently had the mispleasure of trying to empty a bucket with ~600000 objects using CDK's autoDeleteObjects feature. What I observed was that each lambda invocation would get through a few tens of thousands of objects in relatively good time (a few minutes), then the lambda would grind to a halt doing very little until it reached its 15 minute timeout. This process then repeats with subsequent invocations of the lambda. I had to empty the bucket in the web console to make real progress toward deleting the bucket.

Expected Behavior

Lambda does not hang.

Current Behavior

Lambda hangs.

Reproduction Steps

import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as s3 from 'aws-cdk-lib/aws-s3';

export class CdkTestStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    new s3.Bucket(this, 'Bucket', {
      bucketName: 'isker-test',
      autoDeleteObjects: true,
      removalPolicy: cdk.RemovalPolicy.DESTROY
    })
  }
}

Load the resulting bucket with 100000 objects. Destroy the stack, and observe the lambda hanging until it hits its 15 minute timeout.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.124

Framework Version

No response

Node.js Version

20.11.1

OS

macOS

Language

TypeScript

Language Version

No response

Other information

I am filing this issue retroactively in order that my fix for it be merged. #30209

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-s3Related to Amazon S3bugThis issue is a bug.effort/mediumMedium work item – several days of effortp1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions