When deleting the empty bucket, BucketNotEmpty error is returned #2081
-
Describe the bugWhen we use the SDK API For instance, suppose there is a for-loop to create a bucket and then delete it continuously, e.g.: var bucketName = "xxx-xxx";
for (int i = 0; i < 100; i++) {
await CreateBucketAsync(amazonS3Client, bucketName); // calls PutBucket
... // Some operations to upload objects and then download them
await DeleteBucketContentsAsync(amazonS3Client, bucketName); // calls DeleteObjectAsync
await DeleteBucketAsync(amazonS3Client, bucketName); // calls `DeleteBucketAsync` and fails here with BucketNotEmpty error code
} The failure behavior is not deterministic, but we encountered this situation many times. Expected BehaviorWe are wondering whether reusing the same bucket name causes this problem since we noticed that the previous S3 document said that:
as shown in this post: https://serverfault.com/questions/554374/how-long-before-an-s3-bucket-can-be-created-with-same-name-after-deletion However, we cannot find this description anymore, so we expect the same bucket name should be reusable immediately. Current BehaviorCurrently when deleting the content of the bucket, it will throw an AmazonS3Exception with the error message "The bucket you tried to delete is not empty". The stack trace for the previous example
Reproduction StepsAs described before, use a for-loop to create and delete the bucket continuously. Possible SolutionNo response Additional Information/ContextNo response AWS .NET SDK and/or Package version usedAWSSDK.S3 3.7.9.31 Targeted .NET Platform.NET 6 Operating System and versionWindows 10 Pro |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I add a 100ms delay before the Is this problem related to the consistency model of AWS S3?
If I understand correctly, the S3 object write operation is guaranteed but the bucket write operation is not. However, my
|
Beta Was this translation helpful? Give feedback.
-
Hi @darknesschen, Good morning. The behavior documented by you is controlled by the S3 service. Deleting objects could take some time to synchronize. You could implement retry mechanism as per logic in UtilityMethods.DeleteS3BucketWithObjectsAsync(). Thanks, |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
Hi @darknesschen,
Good morning.
The behavior documented by you is controlled by the S3 service. Deleting objects could take some time to synchronize. You could implement retry mechanism as per logic in UtilityMethods.DeleteS3BucketWithObjectsAsync().
Thanks,
Ashish