From c761f9e1aa2e311dcbbea665c311affeeea37f6a Mon Sep 17 00:00:00 2001 From: sylvain senechal Date: Wed, 24 Jun 2026 17:57:44 +0200 Subject: [PATCH 1/3] fix bug with count items hanging when ran against 0 buckets Issue: S3UTILS-243 --- CountItems/CountManager.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CountItems/CountManager.js b/CountItems/CountManager.js index f4d4c1ae..6ca02865 100644 --- a/CountItems/CountManager.js +++ b/CountItems/CountManager.js @@ -214,6 +214,10 @@ class CountManager { } }); this.q.resume(); + if (this.q.idle()) { + this.log.info('no buckets to process, skipping count'); + process.nextTick(onceCB); + } } } From 24d04b40efa4313d93fa28ed2cca2be5019c0b56 Mon Sep 17 00:00:00 2001 From: sylvain senechal Date: Thu, 25 Jun 2026 10:32:23 +0200 Subject: [PATCH 2/3] add defensive code around replicationInfo Issue: S3UTILS-243 --- utils/S3UtilsMongoClient.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/S3UtilsMongoClient.js b/utils/S3UtilsMongoClient.js index ccd7803f..2a046204 100644 --- a/utils/S3UtilsMongoClient.js +++ b/utils/S3UtilsMongoClient.js @@ -280,7 +280,7 @@ class S3UtilsMongoClient extends MongoClientInterface { targetCount = 'versionCount'; targetData = 'versionData'; - if (entry.value.replicationInfo.backends.length > 0 + if (entry.value.replicationInfo?.backends?.length > 0 && this._isReplicationEntryStalled(entry, cmpDate)) { stalledCount++; } @@ -511,7 +511,7 @@ class S3UtilsMongoClient extends MongoClientInterface { }; // only count it in current dataStore if object is not in transient or replication not completed - if (!isTransient || entry.value.replicationInfo.status !== 'COMPLETED') { + if (!isTransient || entry.value.replicationInfo?.status !== 'COMPLETED') { results.location[entry.value.dataStoreName] = size; // We do not support restores to custom location yet. If we do, // the destination would be present in the object metadata. For now, @@ -523,7 +523,7 @@ class S3UtilsMongoClient extends MongoClientInterface { results.location[bucketInfo.getLocationConstraint()] = size; } } - entry.value.replicationInfo.backends.forEach(rep => { + entry.value.replicationInfo?.backends?.forEach(rep => { // count it in the replication destination location if replication compeleted if (rep.status === 'COMPLETED') { results.location[rep.site] = size; From f4ea39f5e879072f3c5d44f413dade0cdc05ae3c Mon Sep 17 00:00:00 2001 From: sylvain senechal Date: Thu, 25 Jun 2026 10:48:52 +0200 Subject: [PATCH 3/3] fix broken test because of empty bucketInfos not properly created Issue: S3UTILS-243 --- tests/unit/CountItems/CountManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/CountItems/CountManager.js b/tests/unit/CountItems/CountManager.js index 53fbed41..3cd82ac6 100644 --- a/tests/unit/CountItems/CountManager.js +++ b/tests/unit/CountItems/CountManager.js @@ -983,8 +983,8 @@ describe('CountItems::CountManager', () => { }); const bucketList = { bucketCount: 10, - bucketInfos: Array(10) - .map(() => BucketInfo.deSerialize(testBucketMD)), + bucketInfos: Array(10).fill() + .map(() => BucketInfo.deSerialize(stringifiedBucketMD)), }; m.addWork(bucketList); const testCB = jest.fn();