@@ -891,6 +891,22 @@ BucketList::scanForEviction(Application& app, AbstractLedgerTxn& ltx,
891
891
auto initialLevel = evictionIter.bucketListLevel ;
892
892
auto initialIsCurr = evictionIter.isCurrBucket ;
893
893
auto b = getBucketFromIter (evictionIter);
894
+
895
+ // Check to see if we can finish scanning the bucket before it receives
896
+ // an update
897
+ auto period = bucketUpdatePeriod (evictionIter.bucketListLevel ,
898
+ evictionIter.isCurrBucket );
899
+
900
+ // Ledgers remaining until the current Bucket changes
901
+ auto ledgersRemainingToScanBucket = period - (ledgerSeq % period);
902
+ auto bytesRemaining = b->getSize () - evictionIter.bucketFileOffset ;
903
+ if (ledgersRemainingToScanBucket * scanSize < bytesRemaining)
904
+ {
905
+ CLOG_WARNING (Bucket,
906
+ " Bucket too large for current eviction scan size." );
907
+ incompleteBucketScanCounter.inc ();
908
+ }
909
+
894
910
while (!b->scanForEviction (
895
911
ltx, evictionIter, scanSize, maxEntriesToEvict, ledgerSeq,
896
912
entriesEvictedMeter, bytesScannedForEvictionCounter))
@@ -926,17 +942,6 @@ BucketList::scanForEviction(Application& app, AbstractLedgerTxn& ltx,
926
942
}
927
943
928
944
b = getBucketFromIter (evictionIter);
929
-
930
- // Check to see if we can finish scanning the new bucket before it
931
- // receives an update
932
- auto period = bucketUpdatePeriod (evictionIter.bucketListLevel ,
933
- evictionIter.isCurrBucket );
934
- if (period * scanSize < b->getSize ())
935
- {
936
- CLOG_WARNING (
937
- Bucket, " Bucket too large for current eviction scan size." );
938
- incompleteBucketScanCounter.inc ();
939
- }
940
945
}
941
946
942
947
networkConfig.updateEvictionIterator (ltx, evictionIter);
0 commit comments