@@ -889,6 +889,22 @@ BucketList::scanForEviction(Application& app, AbstractLedgerTxn& ltx,
889
889
auto initialLevel = evictionIter.bucketListLevel ;
890
890
auto initialIsCurr = evictionIter.isCurrBucket ;
891
891
auto b = getBucketFromIter (evictionIter);
892
+
893
+ // Check to see if we can finish scanning the bucket before it receives
894
+ // an update
895
+ auto period = bucketUpdatePeriod (evictionIter.bucketListLevel ,
896
+ evictionIter.isCurrBucket );
897
+
898
+ // Ledgers remaining until the current Bucket changes
899
+ auto ledgersRemainingToScanBucket = period - (ledgerSeq % period);
900
+ auto bytesRemaining = b->getSize () - evictionIter.bucketFileOffset ;
901
+ if (ledgersRemainingToScanBucket * scanSize < bytesRemaining)
902
+ {
903
+ CLOG_WARNING (Bucket,
904
+ " Bucket too large for current eviction scan size." );
905
+ counters.incompleteBucketScan .inc ();
906
+ }
907
+
892
908
while (!b->scanForEviction (
893
909
ltx, evictionIter, scanSize, maxEntriesToEvict, ledgerSeq,
894
910
counters.entriesEvicted , counters.bytesScannedForEviction ,
@@ -945,17 +961,6 @@ BucketList::scanForEviction(Application& app, AbstractLedgerTxn& ltx,
945
961
}
946
962
947
963
b = getBucketFromIter (evictionIter);
948
-
949
- // Check to see if we can finish scanning the new bucket before it
950
- // receives an update
951
- auto period = bucketUpdatePeriod (evictionIter.bucketListLevel ,
952
- evictionIter.isCurrBucket );
953
- if (period * scanSize < b->getSize ())
954
- {
955
- CLOG_WARNING (
956
- Bucket, " Bucket too large for current eviction scan size." );
957
- counters.incompleteBucketScan .inc ();
958
- }
959
964
}
960
965
961
966
networkConfig.updateEvictionIterator (ltx, evictionIter);
0 commit comments