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
778
778
const long long totalRecs = collection->numRecords (opCtx);
779
779
if (totalRecs > 0 ) {
780
780
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
+ }
781
787
maxRecsWhenFull = _args.getMaxChunkSizeBytes () / avgRecSize;
782
788
maxRecsWhenFull = 130 * maxRecsWhenFull / 100 ; // pad some slack
783
789
} else {
You can’t perform that action at this time.
0 commit comments