Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions tests/functional/aws-node-sdk/test/versioning/multiObjectDelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,31 @@ describe('Multi-Object Versioning Delete Success', function success() {
objects.push(`${key}${i}`);
}

// Create objects in batches of 20 concurrently
// Create objects in batches of 20 concurrently. Fast connections in a
// batch can sit idle while Promise.all waits for slower ones; if the
// server closes them (keepAliveTimeout 5s), the next batch gets ECONNRESET.
// Retrying recovers from that transient race.
const putWithRetry = async (params, attempt = 0) => {
try {
return await s3.send(new PutObjectCommand(params));
} catch (err) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We could filter and retry only on ECONNRESET.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There could be multiple network error arising depending on the race case, for example ECONNRESET or TimeoutError: socket hang up.

We should not have any case where we have a permanent error in here, so I'd say it's not that bad if we retry 3 times any kind of error

if (attempt < 3) {
process.stdout.write(`Retrying PutObject ${params.Key} `
+ `(attempt ${attempt + 1}/3): ${err}\n`);
return putWithRetry(params, attempt + 1);
}
throw err;
}
};
const results = [];
for (let i = 0; i < objects.length; i += 20) {
const batch = objects.slice(i, i + 20);
const batchPromises = batch.map(async keyName => {
const res = await s3.send(new PutObjectCommand({
const res = await putWithRetry({
Bucket: bucketName,
Key: keyName,
Body: 'somebody',
}));
});
res.Key = keyName;
return res;
});
Expand Down
Loading