Skip to content

Commit b2038d5

Browse files
committed
Don't scan protocol 19 buckets for eviction
1 parent a2adbb1 commit b2038d5

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

Diff for: src/bucket/Bucket.cpp

+9-7
Original file line numberDiff line numberDiff line change
@@ -838,20 +838,22 @@ mergeCasesWithEqualKeys(MergeCounters& mc, BucketInputIterator& oi,
838838

839839
bool
840840
Bucket::scanForEviction(AbstractLedgerTxn& ltx, EvictionIterator& iter,
841-
uint64_t& bytesToScan, uint32_t& maxEntriesToEvict,
842-
uint32_t ledgerSeq,
841+
uint64_t& bytesToScan,
842+
uint32_t& remainingEntriesToEvict, uint32_t ledgerSeq,
843843
medida::Counter& entriesEvictedCounter,
844844
medida::Counter& bytesScannedForEvictionCounter,
845845
std::optional<EvictionMetrics>& metrics)
846846
{
847847
ZoneScoped;
848-
if (isEmpty())
848+
if (isEmpty() ||
849+
protocolVersionIsBefore(getBucketVersion(shared_from_this()),
850+
SOROBAN_PROTOCOL_VERSION))
849851
{
850-
// EOF
852+
// EOF, skip to next bucket
851853
return false;
852854
}
853855

854-
if (maxEntriesToEvict == 0 || bytesToScan == 0)
856+
if (remainingEntriesToEvict == 0 || bytesToScan == 0)
855857
{
856858
// Reached end of scan region
857859
return true;
@@ -908,7 +910,7 @@ Bucket::scanForEviction(AbstractLedgerTxn& ltx, EvictionIterator& iter,
908910
ltx.erase(ttlKey);
909911
ltx.erase(LedgerEntryKey(le));
910912
entriesEvictedCounter.inc();
911-
--maxEntriesToEvict;
913+
--remainingEntriesToEvict;
912914
}
913915

914916
stream.seek(initialStreamPos);
@@ -925,7 +927,7 @@ Bucket::scanForEviction(AbstractLedgerTxn& ltx, EvictionIterator& iter,
925927
bytesToScan = 0;
926928
return true;
927929
}
928-
else if (maxEntriesToEvict == 0)
930+
else if (remainingEntriesToEvict == 0)
929931
{
930932
return true;
931933
}

Diff for: src/bucket/Bucket.h

+7-6
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,15 @@ class Bucket : public std::enable_shared_from_this<Bucket>,
137137
static std::string randomBucketName(std::string const& tmpDir);
138138
static std::string randomBucketIndexName(std::string const& tmpDir);
139139

140-
// Returns false if eof reached, true otherwise. Modifies iter as the bucket
141-
// is scanned. Also modifies bytesToScan and maxEntriesToEvict such that
142-
// after this function returns:
140+
// Returns false if eof reached or if Bucket protocol version < 20, true
141+
// otherwise. Modifies iter as the bucket is scanned. Also modifies
142+
// bytesToScan and remainingEntriesToEvict such that after this function
143+
// returns:
143144
// bytesToScan -= amount_bytes_scanned
144-
// maxEntriesToEvict -= entries_evicted
145+
// remainingEntriesToEvict -= entries_evicted
145146
bool scanForEviction(AbstractLedgerTxn& ltx, EvictionIterator& iter,
146-
uint64_t& bytesToScan, uint32_t& maxEntriesToEvict,
147-
uint32_t ledgerSeq,
147+
uint64_t& bytesToScan,
148+
uint32_t& remainingEntriesToEvict, uint32_t ledgerSeq,
148149
medida::Counter& entriesEvictedCounter,
149150
medida::Counter& bytesScannedForEvictionCounter,
150151
std::optional<EvictionMetrics>& metrics);

0 commit comments

Comments
 (0)