Skip to content

Commit

Permalink
Temper excessive warnings about historical shard
Browse files Browse the repository at this point in the history
capacity
  • Loading branch information
undertome committed Oct 20, 2020
1 parent 0b4e34b commit 4e9bae3
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/ripple/nodestore/impl/DatabaseShardImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,9 @@ DatabaseShardImp::import(Database& source)
true,
boost::none);
success = true;

if (shardIndex < shardBoundaryIndex())
++numHistShards;
}
catch (std::exception const& e)
{
Expand Down Expand Up @@ -1409,10 +1412,20 @@ DatabaseShardImp::setFileStats()
fdRequired_ = sumFd;
avgShardFileSz_ = (numShards == 0 ? fileSz_ : fileSz_ / numShards);

if (!canAdd_)
return;

if (auto const count = numHistoricalShards(lock);
count >= maxHistoricalShards_)
{
JLOG(j_.warn()) << "maximum number of historical shards reached";
if (maxHistoricalShards_)
{
// In order to avoid excessive output, don't produce
// this warning if the server isn't configured to
// store historical shards.
JLOG(j_.warn()) << "maximum number of historical shards reached";
}

canAdd_ = false;
}
else if (!sufficientStorage(
Expand All @@ -1422,6 +1435,8 @@ DatabaseShardImp::setFileStats()
{
JLOG(j_.warn())
<< "maximum shard store size exceeds available storage space";

canAdd_ = false;
}
}

Expand Down Expand Up @@ -1561,14 +1576,17 @@ DatabaseShardImp::removeFailedShard(std::shared_ptr<Shard>& shard)
std::uint32_t
DatabaseShardImp::shardBoundaryIndex() const
{
auto const validIndex = app_.getLedgerMaster().getValidLedgerIndex();

if (validIndex < earliestLedgerSeq())
return validIndex;

// Shards with an index earlier than the recent shard boundary index
// are considered historical. The three shards at or later than
// this index consist of the two most recently validated shards
// and the shard still in the process of being built by live
// transactions.
return NodeStore::seqToShardIndex(
app_.getLedgerMaster().getValidLedgerIndex(), ledgersPerShard_) -
1;
return seqToShardIndex(validIndex) - 1;
}

std::uint32_t
Expand Down

0 comments on commit 4e9bae3

Please sign in to comment.