mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 05:55:51 +00:00
Revert support for deterministic shards:
Commit 4dc08f8202 introduced support for
deterministic shards, which makes the sharding functionality provided
by rippled more useful.
After merging, several opportunities for further improvements to the
deterministic sharding implementation were identified and a significant
increase int memory usage during shard finalization was detected.
Because of these issues, the commit is being reverted and the feature is
being rolled back. It will be reintroduced in a future release.
This commit is contained in:
committed by
Nik Bougalis
parent
12c0e8148b
commit
dbd5f0073e
@@ -40,7 +40,6 @@ Shard::Shard(
|
||||
std::uint32_t index,
|
||||
beast::Journal j)
|
||||
: app_(app)
|
||||
, db_(db)
|
||||
, index_(index)
|
||||
, firstSeq_(db.firstLedgerSeq(index))
|
||||
, lastSeq_(std::max(firstSeq_, db.lastLedgerSeq(index)))
|
||||
@@ -393,8 +392,7 @@ Shard::isLegacy() const
|
||||
bool
|
||||
Shard::finalize(
|
||||
bool const writeSQLite,
|
||||
boost::optional<uint256> const& expectedHash,
|
||||
const bool writeDeterministicShard)
|
||||
boost::optional<uint256> const& expectedHash)
|
||||
{
|
||||
assert(backend_);
|
||||
|
||||
@@ -508,17 +506,6 @@ Shard::finalize(
|
||||
std::shared_ptr<Ledger const> next;
|
||||
auto const lastLedgerHash{hash};
|
||||
|
||||
std::shared_ptr<DeterministicShard> dsh;
|
||||
if (writeDeterministicShard)
|
||||
{
|
||||
dsh = std::make_shared<DeterministicShard>(
|
||||
app_, db_, index_, lastLedgerHash, j_);
|
||||
if (!dsh->init())
|
||||
{
|
||||
return fail("can't create deterministic shard");
|
||||
}
|
||||
}
|
||||
|
||||
// Start with the last ledger in the shard and walk backwards from
|
||||
// child to parent until we reach the first ledger
|
||||
seq = lastSeq_;
|
||||
@@ -555,11 +542,8 @@ Shard::finalize(
|
||||
return fail("missing root TXN node");
|
||||
}
|
||||
|
||||
if (dsh)
|
||||
dsh->store(nObj);
|
||||
|
||||
if (!verifyLedger(ledger, next, dsh))
|
||||
return fail("verification check failed");
|
||||
if (!valLedger(ledger, next))
|
||||
return fail("failed to validate ledger");
|
||||
|
||||
if (writeSQLite)
|
||||
{
|
||||
@@ -620,12 +604,6 @@ Shard::finalize(
|
||||
{
|
||||
backend_->store(nObj);
|
||||
|
||||
if (dsh)
|
||||
{
|
||||
dsh->store(nObj);
|
||||
dsh->flush();
|
||||
}
|
||||
|
||||
std::lock_guard lock(mutex_);
|
||||
final_ = true;
|
||||
|
||||
@@ -645,23 +623,6 @@ Shard::finalize(
|
||||
std::string("exception ") + e.what() + " in function " + __func__);
|
||||
}
|
||||
|
||||
if (dsh)
|
||||
{
|
||||
/* Close non-deterministic shard database. */
|
||||
backend_->close();
|
||||
/* Replace non-deterministic shard by deterministic one. */
|
||||
dsh->close();
|
||||
/* Re-open deterministic shard database. */
|
||||
backend_->open(false);
|
||||
/** The finalize() function verifies the shard and, if third parameter
|
||||
* is true, then replaces the shard by deterministic copy of the shard.
|
||||
* After deterministic shard is created it verifies again,
|
||||
* the finalize() function called here to verify deterministic shard,
|
||||
* third parameter is false.
|
||||
*/
|
||||
return finalize(false, expectedHash, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -964,10 +925,9 @@ Shard::setFileStats(std::lock_guard<std::recursive_mutex> const&)
|
||||
}
|
||||
|
||||
bool
|
||||
Shard::verifyLedger(
|
||||
Shard::valLedger(
|
||||
std::shared_ptr<Ledger const> const& ledger,
|
||||
std::shared_ptr<Ledger const> const& next,
|
||||
std::shared_ptr<DeterministicShard> dsh) const
|
||||
std::shared_ptr<Ledger const> const& next) const
|
||||
{
|
||||
auto fail = [j = j_, index = index_, &ledger](std::string const& msg) {
|
||||
JLOG(j.fatal()) << "shard " << index << ". " << msg
|
||||
@@ -986,14 +946,11 @@ Shard::verifyLedger(
|
||||
return fail("Invalid ledger account hash");
|
||||
|
||||
bool error{false};
|
||||
auto visit = [this, &error, dsh](SHAMapAbstractNode& node) {
|
||||
auto visit = [this, &error](SHAMapAbstractNode& node) {
|
||||
if (stop_)
|
||||
return false;
|
||||
auto nObj = valFetch(node.getNodeHash().as_uint256());
|
||||
if (!nObj)
|
||||
if (!valFetch(node.getNodeHash().as_uint256()))
|
||||
error = true;
|
||||
else if (dsh)
|
||||
dsh->store(nObj);
|
||||
return !error;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user