Skip to content

Commit

Permalink
Account for invalid avgObjSize
Browse files Browse the repository at this point in the history
  • Loading branch information
gagik committed Oct 9, 2024
1 parent c203775 commit bdff836
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/shell-api/src/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2186,10 +2186,13 @@ export default class Collection extends ShellApiWithMongoClass {
// Since 6.0, there can be orphan documents indicated by numOrphanDocs.
// These orphan documents need to be accounted for in the size calculation.
const orphanDocumentsCount =
extractedShardStats.storageStats.numOrphanDocs ?? 0;
typeof extractedShardStats.storageStats.numOrphanDocs === 'number'
? extractedShardStats.storageStats.numOrphanDocs
: 0;
const ownedSize =
extractedShardStats.storageStats.size -
orphanDocumentsCount * extractedShardStats.storageStats.avgObjSize;
orphanDocumentsCount *
(extractedShardStats.storageStats.avgObjSize ?? 0);

const shardStats = {
shardId: shard,
Expand Down

0 comments on commit bdff836

Please sign in to comment.