mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Implement node-to-shard RPC control
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <ripple/app/ledger/LedgerMaster.h>
|
||||
#include <ripple/app/ledger/LedgerToJson.h>
|
||||
#include <ripple/app/misc/LoadFeeTrack.h>
|
||||
#include <ripple/app/misc/SHAMapStore.h>
|
||||
#include <ripple/app/rdb/backend/RelationalDBInterfaceSqlite.h>
|
||||
#include <ripple/basics/Slice.h>
|
||||
@@ -263,6 +264,10 @@ class DatabaseShard_test : public TestBase
|
||||
{
|
||||
using namespace test::jtx;
|
||||
|
||||
// The local fee may go up, especially in the online delete tests
|
||||
while (env_.app().getFeeTrack().lowerLocalFee())
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
|
||||
if (isNewAccounts(seq))
|
||||
env_.fund(XRP(iniAmount), accounts_[nAccounts_[seq] - 1]);
|
||||
|
||||
@@ -1249,14 +1254,22 @@ class DatabaseShard_test : public TestBase
|
||||
Database& ndb = env.app().getNodeStore();
|
||||
BEAST_EXPECT(db);
|
||||
|
||||
auto& store = env.app().getSHAMapStore();
|
||||
|
||||
// Allow online delete to delete the startup ledgers
|
||||
// so that it will take some time for the import to
|
||||
// catch up to the point of the next rotation
|
||||
store.setCanDelete(10);
|
||||
|
||||
// Create some ledgers for the shard store to import
|
||||
auto const shardCount = 5;
|
||||
TestData data(seedValue, 4, shardCount);
|
||||
if (!BEAST_EXPECT(data.makeLedgers(env)))
|
||||
return;
|
||||
|
||||
auto& store = env.app().getSHAMapStore();
|
||||
auto lastRotated = store.getLastRotated();
|
||||
store.rendezvous();
|
||||
auto const lastRotated = store.getLastRotated();
|
||||
BEAST_EXPECT(lastRotated >= 553 && lastRotated < 1103);
|
||||
|
||||
// Start the import
|
||||
db->importDatabase(ndb);
|
||||
@@ -1267,37 +1280,45 @@ class DatabaseShard_test : public TestBase
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
|
||||
// Enable online deletion now that the import has started
|
||||
// Enable unimpeded online deletion now that the import has started
|
||||
store.setCanDelete(std::numeric_limits<std::uint32_t>::max());
|
||||
|
||||
auto pauseVerifier = std::thread([lastRotated, &store, db, this] {
|
||||
while (true)
|
||||
// The import should still be running when this thread starts
|
||||
BEAST_EXPECT(db->getDatabaseImportSequence());
|
||||
auto rotationProgress = lastRotated;
|
||||
while (auto const ledgerSeq = db->getDatabaseImportSequence())
|
||||
{
|
||||
// Make sure database rotations dont interfere
|
||||
// with the import
|
||||
|
||||
if (store.getLastRotated() != lastRotated)
|
||||
auto const last = store.getLastRotated();
|
||||
if (last != rotationProgress)
|
||||
{
|
||||
// A rotation occurred during shard import. Not
|
||||
// necessarily an error
|
||||
|
||||
auto const ledgerSeq = db->getDatabaseImportSequence();
|
||||
BEAST_EXPECT(!ledgerSeq || ledgerSeq >= lastRotated);
|
||||
|
||||
break;
|
||||
BEAST_EXPECT(
|
||||
!ledgerSeq || ledgerSeq >= rotationProgress);
|
||||
rotationProgress = last;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
auto join = [&pauseVerifier]() {
|
||||
if (pauseVerifier.joinable())
|
||||
pauseVerifier.join();
|
||||
};
|
||||
|
||||
// Create more ledgers to trigger online deletion
|
||||
data = TestData(seedValue * 2);
|
||||
if (!BEAST_EXPECT(data.makeLedgers(env, shardCount)))
|
||||
{
|
||||
pauseVerifier.join();
|
||||
join();
|
||||
return;
|
||||
}
|
||||
|
||||
pauseVerifier.join();
|
||||
join();
|
||||
BEAST_EXPECT(store.getLastRotated() != lastRotated);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user