remove readthrough and have minimum limit for the getRange

This commit is contained in:
Jon Fu 2022-11-09 10:45:19 -08:00
parent 8ef0411b32
commit f08b2b86d9
2 changed files with 5 additions and 11 deletions

View File

@ -168,7 +168,6 @@ template <typename ResultType>
struct KeyBackedRangeResult {
std::vector<ResultType> results;
bool more;
Optional<KeyRef> readThrough;
};
// Convenient read/write access to a single value of type T stored at key
@ -369,7 +368,6 @@ public:
rangeResult.results.push_back(PairType(key, val));
}
rangeResult.more = kvs.more;
rangeResult.readThrough = kvs.readThrough;
return rangeResult;
}));
}
@ -575,7 +573,6 @@ public:
rangeResult.results.push_back(PairType(key, val));
}
rangeResult.more = kvs.more;
rangeResult.readThrough = kvs.readThrough;
return rangeResult;
}));
}
@ -663,7 +660,6 @@ public:
rangeResult.results.push_back(Codec::unpack(kvs[i].key.removePrefix(prefix)));
}
rangeResult.more = kvs.more;
rangeResult.readThrough = kvs.readThrough;
return rangeResult;
}));
}

View File

@ -1589,7 +1589,8 @@ Future<std::vector<std::pair<TenantName, TenantMapEntry>>> listTenants(
tr->setOption(FDBTransactionOptions::RAW_ACCESS);
state KeyBackedRangeResult<std::pair<TenantName, TenantMapEntry>> results =
wait(ManagementClusterMetadata::tenantMetadata().tenantMap.getRange(tr, begin, end, limit));
wait(ManagementClusterMetadata::tenantMetadata().tenantMap.getRange(
tr, begin, end, std::max(limit + offset, 100)));
state std::vector<std::pair<TenantName, TenantMapEntry>> filterResults;
state int count = 0;
loop {
@ -1608,13 +1609,10 @@ Future<std::vector<std::pair<TenantName, TenantMapEntry>>> listTenants(
if (!results.more) {
return filterResults;
}
if (results.readThrough.present()) {
begin = results.readThrough.get();
} else {
begin = keyAfter(results.results.back().first);
}
begin = keyAfter(results.results.back().first);
wait(store(results,
ManagementClusterMetadata::tenantMetadata().tenantMap.getRange(tr, begin, end, limit)));
ManagementClusterMetadata::tenantMetadata().tenantMap.getRange(
tr, begin, end, std::max(limit + offset, 100))));
}
} catch (Error& e) {
wait(safeThreadFutureToFuture(tr->onError(e)));