Skip to content

Commit 9845756

Browse files
committed
Merge branch 'bugfix/CLDSRV-835-mongo-econreset' into tmp/octopus/w/9.4/bugfix/CLDSRV-835-mongo-econreset
2 parents 3db6c18 + 5ac52b8 commit 9845756

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

tests/functional/aws-node-sdk/test/versioning/multiObjectDelete.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,31 @@ describe('Multi-Object Versioning Delete Success', function success() {
5656
objects.push(`${key}${i}`);
5757
}
5858

59-
// Create objects in batches of 20 concurrently
59+
// Create objects in batches of 20 concurrently. Fast connections in a
60+
// batch can sit idle while Promise.all waits for slower ones; if the
61+
// server closes them (keepAliveTimeout 5s), the next batch gets ECONNRESET.
62+
// Retrying recovers from that transient race.
63+
const putWithRetry = async (params, attempt = 0) => {
64+
try {
65+
return await s3.send(new PutObjectCommand(params));
66+
} catch (err) {
67+
if (attempt < 3) {
68+
process.stdout.write(`Retrying PutObject ${params.Key} `
69+
+ `(attempt ${attempt + 1}/3): ${err}\n`);
70+
return putWithRetry(params, attempt + 1);
71+
}
72+
throw err;
73+
}
74+
};
6075
const results = [];
6176
for (let i = 0; i < objects.length; i += 20) {
6277
const batch = objects.slice(i, i + 20);
6378
const batchPromises = batch.map(async keyName => {
64-
const res = await s3.send(new PutObjectCommand({
79+
const res = await putWithRetry({
6580
Bucket: bucketName,
6681
Key: keyName,
6782
Body: 'somebody',
68-
}));
83+
});
6984
res.Key = keyName;
7085
return res;
7186
});

0 commit comments

Comments
 (0)