@@ -674,20 +674,9 @@ void DbChecker::_extraIndexKeysCheck(OperationContext* opCtx) {
674
674
675
675
int64_t totalBytesSeen = 0 ;
676
676
int64_t totalKeysSeen = 0 ;
677
- using Clock = stdx::chrono::system_clock;
678
- using TimePoint = stdx::chrono::time_point<Clock>;
679
- TimePoint lastStart = Clock::now ();
680
- int64_t docsInCurrentInterval = 0 ;
681
-
682
677
do {
683
- using namespace std ::literals::chrono_literals;
684
-
685
- if (Clock::now () - lastStart > 1s) {
686
- lastStart = Clock::now ();
687
- docsInCurrentInterval = 0 ;
688
- }
689
-
690
678
DbCheckExtraIndexKeysBatchStats batchStats = {0 };
679
+ batchStats.deadline = Date_t::now () + Milliseconds (_info.maxBatchTimeMillis );
691
680
692
681
// 1. Get batch bounds (stored in batchStats) and run reverse lookup if
693
682
// skipLookupForExtraKeys is not set.
@@ -759,21 +748,11 @@ void DbChecker::_extraIndexKeysCheck(OperationContext* opCtx) {
759
748
// 5. Check if we've exceeded any limits.
760
749
_batchesProcessed++;
761
750
totalBytesSeen += batchStats.nBytes ;
762
- totalKeysSeen += batchStats.nDocs ;
763
- docsInCurrentInterval += batchStats.nDocs ;
751
+ totalKeysSeen += batchStats.nKeys ;
764
752
765
- bool tooManyDocs = totalKeysSeen >= _info.maxCount ;
753
+ bool tooManyKeys = totalKeysSeen >= _info.maxCount ;
766
754
bool tooManyBytes = totalBytesSeen >= _info.maxSize ;
767
- reachedEnd = batchStats.finishedIndexCheck || tooManyDocs || tooManyBytes;
768
-
769
- if (docsInCurrentInterval > _info.maxRate && _info.maxRate > 0 ) {
770
- // If an extremely low max rate has been set (substantially smaller than the
771
- // batch size) we might want to sleep for multiple seconds between batches.
772
- int64_t timesExceeded = docsInCurrentInterval / _info.maxRate ;
773
-
774
- stdx::this_thread::sleep_for (timesExceeded * 1s - (Clock::now () - lastStart));
775
- }
776
-
755
+ reachedEnd = batchStats.finishedIndexCheck || tooManyKeys || tooManyBytes;
777
756
} while (!reachedEnd);
778
757
779
758
// TODO SERVER-79846: Add testing for progress meter
@@ -882,9 +861,8 @@ Status DbChecker::_hashExtraIndexKeysCheck(OperationContext* opCtx,
882
861
return e.toStatus ();
883
862
}
884
863
885
- const auto batchDeadline = Date_t::now () + Milliseconds (_info.maxBatchTimeMillis );
886
- Status status = hasher->hashForExtraIndexKeysCheck (
887
- opCtx, collection.get (), batchFirst, batchLast, batchDeadline);
864
+ Status status =
865
+ hasher->hashForExtraIndexKeysCheck (opCtx, collection.get (), batchFirst, batchLast);
888
866
if (!status.isOK ()) {
889
867
return status;
890
868
}
@@ -1063,8 +1041,8 @@ Status DbChecker::_getCatalogSnapshotAndRunReverseLookup(
1063
1041
const auto ordering = iam->getSortedDataInterface ()->getOrdering ();
1064
1042
1065
1043
1066
- std::unique_ptr<SortedDataInterface::Cursor> indexCursor =
1067
- iam-> newCursor (opCtx, true /* forward */ );
1044
+ auto indexCursor =
1045
+ std::make_unique<SortedDataInterfaceThrottleCursor> (opCtx, iam, &_info. dataThrottle );
1068
1046
1069
1047
1070
1048
// Set the index cursor's end position based on the inputted end parameter for when to stop
@@ -1085,7 +1063,7 @@ Status DbChecker::_getCatalogSnapshotAndRunReverseLookup(
1085
1063
logAttrs (_info.nss ),
1086
1064
" uuid" _attr = _info.uuid );
1087
1065
1088
- auto currIndexKey = indexCursor->seekForKeyString (lookupStart);
1066
+ auto currIndexKey = indexCursor->seekForKeyString (opCtx, lookupStart);
1089
1067
1090
1068
// Note that if we can't find lookupStart (e.g. it was deleted in between snapshots),
1091
1069
// seekForKeyString will automatically return the next adjacent keystring in the storage
@@ -1148,9 +1126,9 @@ Status DbChecker::_getCatalogSnapshotAndRunReverseLookup(
1148
1126
numBytes += keyString.getSize ();
1149
1127
numKeys++;
1150
1128
batchStats.nBytes += keyString.getSize ();
1151
- batchStats.nDocs ++;
1129
+ batchStats.nKeys ++;
1152
1130
1153
- currIndexKey = indexCursor->nextKeyString ();
1131
+ currIndexKey = indexCursor->nextKeyString (opCtx );
1154
1132
1155
1133
// Set nextLookupStart.
1156
1134
if (currIndexKey) {
@@ -1162,8 +1140,7 @@ Status DbChecker::_getCatalogSnapshotAndRunReverseLookup(
1162
1140
// snapshot/batch, so skip this check.
1163
1141
if (!(currIndexKey && (keyString == currIndexKey.get ().keyString ))) {
1164
1142
// Check if we should finish this batch.
1165
- if (batchStats.nBytes >= _info.maxBytesPerBatch ||
1166
- batchStats.nDocs >= _info.maxDocsPerBatch ) {
1143
+ if (batchStats.nKeys >= _info.maxDocsPerBatch ) {
1167
1144
batchStats.finishedIndexBatch = true ;
1168
1145
break ;
1169
1146
}
@@ -1172,6 +1149,11 @@ Status DbChecker::_getCatalogSnapshotAndRunReverseLookup(
1172
1149
break ;
1173
1150
}
1174
1151
}
1152
+
1153
+ if (Date_t::now () > batchStats.deadline ) {
1154
+ batchStats.finishedIndexBatch = true ;
1155
+ break ;
1156
+ }
1175
1157
}
1176
1158
1177
1159
@@ -1211,9 +1193,12 @@ void DbChecker::_reverseLookup(OperationContext* opCtx,
1211
1193
}
1212
1194
MONGO_UNREACHABLE;
1213
1195
}();
1214
- RecordData record;
1215
- bool res = collection->getRecordStore ()->findRecord (opCtx, recordId, &record);
1216
- if (!res) {
1196
+
1197
+ auto seekRecordStoreCursor = std::make_unique<SeekableRecordThrottleCursor>(
1198
+ opCtx, collection->getRecordStore (), &_info.dataThrottle );
1199
+
1200
+ auto record = seekRecordStoreCursor->seekExact (opCtx, recordId);
1201
+ if (!record) {
1217
1202
LOGV2_DEBUG (7844802 ,
1218
1203
3 ,
1219
1204
" reverse lookup failed to find record data" ,
@@ -1247,7 +1232,7 @@ void DbChecker::_reverseLookup(OperationContext* opCtx,
1247
1232
}
1248
1233
1249
1234
// Found record in record store.
1250
- auto recordBson = record.toBson ();
1235
+ auto recordBson = record-> data .toBson ();
1251
1236
1252
1237
// Generate the set of keys for the record data and check that it includes the
1253
1238
// index key.
0 commit comments