File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -778,6 +778,12 @@ Status MigrationChunkClonerSourceLegacy::_storeCurrentLocs(OperationContext* opC
778778 const long long totalRecs = collection->numRecords (opCtx);
779779 if (totalRecs > 0 ) {
780780 avgRecSize = collection->dataSize (opCtx) / totalRecs;
781+ // The calls to numRecords() and dataSize() are not atomic so it is possible that the data
782+ // size becomes smaller than the number of records between the two calls, which would result
783+ // in average record size of zero
784+ if (avgRecSize == 0 ) {
785+ avgRecSize = BSONObj::kMinBSONLength ;
786+ }
781787 maxRecsWhenFull = _args.getMaxChunkSizeBytes () / avgRecSize;
782788 maxRecsWhenFull = 130 * maxRecsWhenFull / 100 ; // pad some slack
783789 } else {
You can’t perform that action at this time.
0 commit comments